Message ID | 20221122023350.29128-1-jiasheng@iscas.ac.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1962917wrr; Mon, 21 Nov 2022 18:37:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Gp8uy6UCs/dz+H5/Mos+4GGmGbJucoUvctCccaepXKiyNFyDMiejUXg1jSyLPdMqhIFtc X-Received: by 2002:a05:6a00:1a14:b0:572:5be2:505b with SMTP id g20-20020a056a001a1400b005725be2505bmr2158134pfv.52.1669084653121; Mon, 21 Nov 2022 18:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669084653; cv=none; d=google.com; s=arc-20160816; b=BH7hkeosMobhSUYMUfa83ys7LyhhdMsM6TbL9c08DvasnWsUms8z4MhuPUsEZtFfxY nmXZEK6ULCHH/W0HfkKbC86Nd/TNUTk9UYOXJX/HREZuphyNZ9GBZiRXf8U82IeAWeJD iffdl1+F8ptHKmG/VevozHKUqqs6DIeadfoT8lniRx+rw4bdxrnYgMy7gKX5Kd1Quut8 4jE4vwX747QODft9zR+qHuhmcc66ykw5idGobXYC3VyTFmVkYkwD2RiU5onkSjC4IXye z20y5w3kvcMHvzU+jlPgb3kFJq5C5ux2s6LIGIWooNDVhl4ZCweD4GRJvJtHdUqXTd13 c1xA== 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; bh=9/SnKXVNYIACLxJHVoJ25LpDfvfiS9NN8QtVIzWrkGk=; b=x/GHQEggGY1TYgRwkgl+XUUUCqc+6o7np24AuJ+JBzmGYs++uqusetPoOz5QfVJNDq 226OGoEsklTqhdU7rgRcsQHNAgvkHmk9luE+lQ8sbhATN3XxAhW+1seZpdUPT9fF6JBj nW6UAK+Hsi9UU8O0DGoPaRIKi8hLh6wjENTw5w7UBdihpR/4ElSuIIWysDdGVTVrf/uj tpgPupq3/RGB1BV7TXVVhoQBXSLyw1TVHBmlUS1brb/Umd+LzQVBJDazTseXu/9SHZbP 162uV/DlPwyLyskcLdeDqBrsZHbSqLC2IAEyEp9lEpBZa/mR/xGm0RtUjxVruofqZDDz +s7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm14-20020a17090b3ece00b002088ad6d93fsi17114220pjb.49.2022.11.21.18.37.20; Mon, 21 Nov 2022 18:37:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbiKVCeI (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Mon, 21 Nov 2022 21:34:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiKVCeG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 21 Nov 2022 21:34:06 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 45F42B97D6 for <linux-kernel@vger.kernel.org>; Mon, 21 Nov 2022 18:34:04 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowABHTe0PNXxjw1WrAA--.4511S2; Tue, 22 Nov 2022 10:33:52 +0800 (CST) From: Jiasheng Jiang <jiasheng@iscas.ac.cn> To: dan.j.williams@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, ira.weiny@intel.com Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, Jiasheng Jiang <jiasheng@iscas.ac.cn> Subject: [PATCH] libnvdimm: Add check for nd_dax_alloc Date: Tue, 22 Nov 2022 10:33:50 +0800 Message-Id: <20221122023350.29128-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowABHTe0PNXxjw1WrAA--.4511S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Jw4kZFWDAFWfCr48ur4rXwb_yoW3Kwb_Kr 17Zr92vFWjkwnayr43tr1fuFyvyr4vgr1kWr4jgry3A3yjkr13XrWkur9xCrZagF48AFnr uw1qvFy7uFyxCjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbwkFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxG rwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4 vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IY x2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26c xKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAF wI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbXdbUUUUUU== X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750162109348501162?= X-GMAIL-MSGID: =?utf-8?q?1750162109348501162?= |
Series |
libnvdimm: Add check for nd_dax_alloc
|
|
Commit Message
Jiasheng Jiang
Nov. 22, 2022, 2:33 a.m. UTC
As the nd_dax_alloc may return NULL pointer,
it should be better to add check for the return
value, as same as the one in nd_dax_create().
Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/nvdimm/dax_devs.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Le 22/11/2022 à 03:33, Jiasheng Jiang a écrit : > As the nd_dax_alloc may return NULL pointer, > it should be better to add check for the return > value, as same as the one in nd_dax_create(). > > Fixes: c5ed9268643c ("libnvdimm, dax: autodetect support") > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> > --- > 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 7f4a9d28b670..9efe62b95dd8 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); Hi, Based on 6.1-rc6 ([1]), the error handling is already in place just after the nvdimm_bus_unlock() call. CJ [1]: https://elixir.bootlin.com/linux/v6.1-rc6/source/drivers/nvdimm/dax_devs.c#L112
diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c index 7f4a9d28b670..9efe62b95dd8 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);