From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751558AbdH2WwF (ORCPT ); Tue, 29 Aug 2017 18:52:05 -0400 Received: from mga11.intel.com ([192.55.52.93]:29565 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240AbdH2WwE (ORCPT ); Tue, 29 Aug 2017 18:52:04 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,446,1498546800"; d="scan'208";a="1009039003" Date: Tue, 29 Aug 2017 16:50:06 -0600 From: Vishal Verma To: Christophe JAILLET Cc: dan.j.williams@intel.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] libnvdimm, btt: check memory allocation failure Message-ID: <20170829225006.GB16374@omniknight.lm.intel.com> References: <20170827063034.4802-1-christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170827063034.4802-1-christophe.jaillet@wanadoo.fr> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/27, Christophe JAILLET wrote: > Check memory allocation failures and return -ENOMEM in such cases, as > already done few lines below for another memory allocation. > > This avoids NULL pointers dereference. > > Fixes: 14e494542636 ("libnvdimm, btt: BTT updates for UEFI 2.7 format") > Signed-off-by: Christophe JAILLET > --- > drivers/nvdimm/btt.c | 2 ++ > 1 file changed, 2 insertions(+) Looks good, thank you. Reviewed-by: Vishal Verma > > diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c > index 60491641a8d6..607184ebcfbf 100644 > --- a/drivers/nvdimm/btt.c > +++ b/drivers/nvdimm/btt.c > @@ -1431,6 +1431,8 @@ int nvdimm_namespace_attach_btt(struct nd_namespace_common *ndns) > } > > btt_sb = devm_kzalloc(&nd_btt->dev, sizeof(*btt_sb), GFP_KERNEL); > + if (!btt_sb) > + return -ENOMEM; > > /* > * If this returns < 0, that is ok as it just means there wasn't > -- > 2.11.0 >