From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_50, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F249CC433B4 for ; Fri, 9 Apr 2021 16:41:50 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 617326108B for ; Fri, 9 Apr 2021 16:41:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 617326108B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3AD9F100EBB75; Fri, 9 Apr 2021 09:41:50 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=ira.weiny@intel.com; receiver= Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0CEA7100EC1D4 for ; Fri, 9 Apr 2021 09:41:46 -0700 (PDT) IronPort-SDR: cfY/1qEpBV6op7AJ3ABn1Fbz7wWw2LJyEcHhw4aohKHbU5xNOz77p3BwyhV092xBozS6lRI/0t +JlGXUzkt+QQ== X-IronPort-AV: E=McAfee;i="6000,8403,9949"; a="279074063" X-IronPort-AV: E=Sophos;i="5.82,209,1613462400"; d="scan'208";a="279074063" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2021 09:41:46 -0700 IronPort-SDR: ln9tRBqUAzx6WVFVR2aPszLeA8Rhu1kRmICVOKiGFRXQ7IH47CsInbY28hob42C65D310519oS gpLb6l0pGjtg== X-IronPort-AV: E=Sophos;i="5.82,209,1613462400"; d="scan'208";a="416332651" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Apr 2021 09:41:46 -0700 Date: Fri, 9 Apr 2021 09:41:45 -0700 From: Ira Weiny To: wangyingjie55@126.com Subject: Re: [PATCH v1] libnvdimm, dax: Fix a missing check in nd_dax_probe() Message-ID: <20210409164145.GQ3014244@iweiny-DESK2.sc.intel.com> References: <1617933506-13684-1-git-send-email-wangyingjie55@126.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1617933506-13684-1-git-send-email-wangyingjie55@126.com> User-Agent: Mutt/1.11.1 (2018-12-01) Message-ID-Hash: QJ446WHWIMRSWH3HDFLESM66FIKMX6MB X-Message-ID-Hash: QJ446WHWIMRSWH3HDFLESM66FIKMX6MB X-MailFrom: ira.weiny@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, Apr 08, 2021 at 06:58:26PM -0700, wangyingjie55@126.com wrote: > From: Yingjie Wang > > In nd_dax_probe(), 'nd_dax' is allocated by nd_dax_alloc(). > nd_dax_alloc() may fail and return NULL, so we should better check Avoid the use of 'we'. > it's return value to avoid a NULL pointer dereference > a bit later in the code. How about: "nd_dax_alloc() may fail and return NULL. Check for NULL before attempting to use nd_dax to avoid a NULL pointer dereference." > > Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support") > Signed-off-by: Yingjie Wang The code looks good though. Ira > --- > drivers/nvdimm/dax_devs.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c > index 99965077bac4..b1426ac03f01 100644 > --- a/drivers/nvdimm/dax_devs.c > +++ b/drivers/nvdimm/dax_devs.c > @@ -106,6 +106,8 @@ int nd_dax_probe(struct device *dev, struct nd_namespace_common *ndns) > > nvdimm_bus_lock(&ndns->dev); > nd_dax = nd_dax_alloc(nd_region); > + if (!nd_dax) > + return -ENOMEM; > nd_pfn = &nd_dax->nd_pfn; > dax_dev = nd_pfn_devinit(nd_pfn, ndns); > nvdimm_bus_unlock(&ndns->dev); > -- > 2.7.4 > _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org