Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4848936imm; Mon, 11 Jun 2018 21:04:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJcZRK5CoNOUdSxQcHuVJvvZZ7ESGD7eJjzzyU5uPS/at4UnfaY7aVEiAWkxRagb159xg1Q X-Received: by 2002:a17:902:74cc:: with SMTP id f12-v6mr2165135plt.7.1528776281370; Mon, 11 Jun 2018 21:04:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528776281; cv=none; d=google.com; s=arc-20160816; b=MZL1Csi42cpUnQusA5d9q3oD2aN9bHukOTQCLfGUViqOMXbXvqQBm8vlfH52D6/PWs X4bJKLGjyIRV1QcZ338EsisyN0oaBF5x4kJIBCo7gUd483WbvJrOHqpfXmK+fAyddAm1 5fxD7oNNMr6AbS1/DHZtaffZ82mh+tGENPAfA/2V2HLBxcoG4eEH/PdecK/qVJUz/Fv6 4+6T5VfMgZPfmFX+eTzqVUrt8A0oFSg+AY1uYdC7znxh8pJfkAp74u4fWIpUg6BhkQXB zKkZwYVJJojvqV6nemKI7RoyOlZkJltbu8T639kPq0WS5dlFoQClLkHprovhHv4j0cDO IStw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=zYdq2o2hPEivRFoImDEtISLRjqAIs4y06nKopbM5QEg=; b=nm+V9j48BhSwZkmL1PtwXOth1Oa/XgaOB5uc+HEmGPYbOzxBTOPkpp1PjI7NEshs8p uS/Mst0lGkgpu9UPTLl8KnNos/inhoi2AmoEhm+2PHM+xYCpNEwDm5kzWUVAfCQW7aiO Tka7GhDPiemnW/zu9RNibGCiq/4V0OxO1rtkq/SzA3bWWoLZeiqT3dAmo3b18Q8ChsW9 UHLakdTnoGCX81sorUmbAMgs4dUMzTMd4BtIG8hNBfOq4bIz4XzmAhGvSyl4n229fFSL aWPC5oTEFp8vYPponG5kkz+6FV+N5GHuBiY6cPIcxK5Caap1ALBwosULlTsGjyqa+bCB NhXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QNRo7INp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10-v6si52821824pgo.679.2018.06.11.21.04.26; Mon, 11 Jun 2018 21:04:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QNRo7INp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933261AbeFLDiS (ORCPT + 99 others); Mon, 11 Jun 2018 23:38:18 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34703 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932650AbeFLDiR (ORCPT ); Mon, 11 Jun 2018 23:38:17 -0400 Received: by mail-pl0-f65.google.com with SMTP id g20-v6so13547349plq.1 for ; Mon, 11 Jun 2018 20:38:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=zYdq2o2hPEivRFoImDEtISLRjqAIs4y06nKopbM5QEg=; b=QNRo7INpqccpgrpZiT2ibtfh2FH0SpCCHMPvqRs8TSt3wRMEtDELTU1+HITGSPJDPo j18nzWyf76WuR6Z5eKQIpkVHZvylmZkKO2aAavl1xR0XkMBMt8CeF+DZTNa5vHutGziK K2wHHx/pihtgRDLyog90xF0ghEti3Z8TD5A1SUY0fOlNUdZ2dCKwzu1gfSR+MBfnwd78 nQRwxwpl9gkFg0EFQIBb8v7j77M0Fh0xP5lJ335g/HkLZXMCgZkQrn2XlR2WNkl2OiTZ jnnyNY6pX3aRKib59HH1izpsRx60I71Lh6NBUAmHve8r8w9H7F/Ll7nf9c7zUQFCV5Cx C06Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zYdq2o2hPEivRFoImDEtISLRjqAIs4y06nKopbM5QEg=; b=Xz2ftVMTzc+nDdI2h639U9UhYylkun5Ml2WukZ9vcMyraGsYo/Qd4RQHCicUf0w23e U3gCFmDccxivSsyJu5Gvp3IWhTtpHgwHPJ98Nh9W+kj78OwjlFLlj064jT+5JpOIl6KU XrMeMEhs934q2iOnSV17B9ZOChG8Gk8lWARNaeUbNofylIfU8lE0myIPfMq3StE57QPM /UoxOWK0JAm6h2Mg+GcAcUDBAM47fbAkhVGaA2ahJcMVA3HGV7MjgcNUdWx4pHuOM/18 +HqcOQ9YTpJw8XFjhexpvEjbZF/XKldnoVq5Q60TlEtwzfhLBJ4/cpyGyD2XdO55AzoK cIpA== X-Gm-Message-State: APt69E2qDYd9G4K0ZI+VM4plblCuQJeXpLyWrGkj3EaNvILaLfA5TQTT B41SwfifN0OvXiHIY3pTGI98s4bfCGU= X-Received: by 2002:a17:902:28a6:: with SMTP id f35-v6mr2091371plb.110.1528774697579; Mon, 11 Jun 2018 20:38:17 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id g4-v6sm74254933pfg.38.2018.06.11.20.38.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 20:38:17 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Bob Peterson , Andreas Gruenbacher , cluster-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH] gfs2: add error handling for kmem_cache_zalloc Date: Tue, 12 Jun 2018 11:38:12 +0800 Message-Id: <1528774692-38990-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When kmem_cache_zalloc fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling kmem_cache_zalloc. Signed-off-by: Zhouyang Jia --- fs/gfs2/trans.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index 064c9a0..da81eb4 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -130,6 +130,9 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl, struct gfs2_bufdata *bd; bd = kmem_cache_zalloc(gfs2_bufdata_cachep, GFP_NOFS | __GFP_NOFAIL); + if (!bd) + return NULL; + bd->bd_bh = bh; bd->bd_gl = gl; bd->bd_ops = lops; -- 2.7.4