Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5223672rwb; Mon, 21 Nov 2022 19:01:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6RP77+i3J6eOxG5mYjOKDaxtisxFdN3p5G3HiSEWjmghXfJ7unE9XL6keRH7yvY/pTRgWL X-Received: by 2002:a63:2251:0:b0:477:9bc8:dffb with SMTP id t17-20020a632251000000b004779bc8dffbmr1527888pgm.306.1669086099269; Mon, 21 Nov 2022 19:01:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669086099; cv=none; d=google.com; s=arc-20160816; b=uKgglDQ0/hAfVkn4N09kLxEh2MXKfSRObjJRtJllkW0C5+GujScTDkVVcWaMN7DPFw maONkEw08+lJyRo5D5HGvugmajgC1/ycYnMcqWtGpFeLj/BHxu33T6uRpPZqdClw9odi 5sn5f09wu3bgqLOwknFDURiKyh3LccwaT25Xpgo6RZtP4AW8mIWKXiDb3Wq2kuCPAHzm j2f5Z+EgTdGiCwIC/gMNkepOCwC51sGPA1lxbmYlcoJ9e5DKbNAYw/5LSxKKRf83gnJV EfqdtHk/tQ2LGyA03gkeiE94W0rSUb2YjGeQJ9FrK/rguI4xyaT6Xrn/7Lyy/egjWNgN ChwA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e15-20020a63db0f000000b0043a20d3388esi12965582pgg.321.2022.11.21.19.01.24; Mon, 21 Nov 2022 19:01:39 -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 + 91 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 ); 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 ; 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 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 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- 2.25.1