Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp197847pxf; Wed, 17 Mar 2021 03:05:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKjuBPPhu85V9LRamgwuE77RCoOmkQnA9uaDlymTX1mYAWUyzODrPGrKcxizY3gZpvRROf X-Received: by 2002:a05:6402:b85:: with SMTP id cf5mr42044309edb.248.1615975548674; Wed, 17 Mar 2021 03:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615975548; cv=none; d=google.com; s=arc-20160816; b=cYGSc6sxQm39psH6/DWFUTauSBeLIqBP4wxK9foq+0uFHNL1BULl0nlD64tQKI0T50 LgSvqaFfrpuA6qJwCiPRKZWT4+Npy9alCPlMxkI7DM4JMy0g/Xoiza1zqc/YoT2xFDyy 4bA2u+16dTkqHg07/Uji49H/lUvzrEQxbIag47cwnC8/w2chyeyKZ2JS+7W7w8YvND7P V+FUjq6FFEQFh6UlVDpeUquJ/OUdgsPiQcaVjmUar25XNSYcXuZ92mjoDrf+X4pVAtkA uDbG429qg9yroHyfOWSLe0bQBPJrzMx+lKlfdDBogmbwEVdMZ3qtDw6F9GzPbLHezwj8 Qkvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7fLA8kcYxRJcVDBSuxgpwdomNhiK47IKlY7AxaYmZnw=; b=Sj5oRgE55mukSWMeUZJewwlLwQ4id2MtYC0GDiHztNtOh2u3D8b4EFvPpQP10vrt7I CKb3ww7DUSxZP+V4WhpbOslEv6GnA5U1g507DiNQ0JfVBJ2wvgsg3QkxV4C2HVKXXDwD pZ1ikOeVrBV1ueEROxIEjMcfmsUZpKt797RTMAPRXmkbk8WlK/WB5eaApVHgljIro44J UQW37LcrI5STMCy27n0vWuCRPbkujQEtnn60HEyXPwWdQPMJXhIQj+QIMoWsVzAPWce7 gZi14H5AD8ow7ioWHmSk04Zq4L+wTIfiH0IEdPvXUkH4J6wbtMWSScIjRBjJfzpzmUMY wHRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=boyhAive; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i15si15020064eje.718.2021.03.17.03.05.25; Wed, 17 Mar 2021 03:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@126.com header.s=s110527 header.b=boyhAive; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=126.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230051AbhCQKD7 (ORCPT + 99 others); Wed, 17 Mar 2021 06:03:59 -0400 Received: from mail-m963.mail.126.com ([123.126.96.3]:43828 "EHLO mail-m963.mail.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbhCQKDi (ORCPT ); Wed, 17 Mar 2021 06:03:38 -0400 X-Greylist: delayed 1823 seconds by postgrey-1.27 at vger.kernel.org; Wed, 17 Mar 2021 06:03:37 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=7fLA8 kcYxRJcVDBSuxgpwdomNhiK47IKlY7AxaYmZnw=; b=boyhAiveS/FGR1K4DYCET OJy/+vSPS9aTFQIruOFGuy85qOvceWj/MnmADCMNdwwcSe5s8waO7/Q6QXhuG6go ALWXN5q5KLhEQlnkXHNqXsjq3dk8756U/1f6NQisKgO7XeO+rD3pezwt02wX6pvU c3IZqmvMEx8hGF1t3NZAVA= Received: from localhost.localdomain (unknown [116.162.2.6]) by smtp8 (Coremail) with SMTP id NORpCgBHSz_LzFFgkSgYFw--.18768S2; Wed, 17 Mar 2021 17:32:59 +0800 (CST) From: wangyingjie55@126.com To: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com Cc: wangyingjie55@126.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] libnvdimm, dax: Fix a missing check in nd_dax_probe() Date: Wed, 17 Mar 2021 02:32:37 -0700 Message-Id: <1615973557-15889-1-git-send-email-wangyingjie55@126.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit X-CM-TRANSID: NORpCgBHSz_LzFFgkSgYFw--.18768S2 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjxU49YFUUUUU X-Originating-IP: [116.162.2.6] X-CM-SenderInfo: 5zdqw5xlqjyxrhvvqiyswou0bp/1tbiHQxYp1pEC+cFvAAAsl Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 it's return value to avoid a NULL pointer dereference a bit later in the code. Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support") Signed-off-by: Yingjie Wang --- 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