Message ID | 20221122033244.5777-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 q4csp1984231wrr; Mon, 21 Nov 2022 19:43:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4bbrlNxbLtMkBBw5LIrT8UH0fHiU8MvASp4Ebj3MY7GMJroxhzdzXAft8+DYJkRcsLGpj8 X-Received: by 2002:a17:90a:7f86:b0:218:9ea6:6593 with SMTP id m6-20020a17090a7f8600b002189ea66593mr12367496pjl.196.1669088613148; Mon, 21 Nov 2022 19:43:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669088613; cv=none; d=google.com; s=arc-20160816; b=dO3V0fcpsTOzM4IxAvp7Ve1JtxMY04410CSvDPQ/Wb/ih+ZHbUFPP5p4D15qcVDwNm Mr3oTYtfsD6wfQbwlgC9P2rodCLw36Op0HFNgP+PDjRlSW5LRM/NGsjAQr/8qXGNDRHZ HZ4teF7LWSP7U5zchQXOAyVqJP2U/ERCzWCsvbq6cZL4VPO6RKgB8K3hBQ9ZIUF8vPrb kf+LKSw2PyFv1VIfzLYVwuDTPeASTJkNu5pJyAe4LjCdFJMTnpnj6b5VnlCLAXvhco++ gF+9vLC+7ZwhmgdCi2ndA9qz1gYG95Zdv8G/v4ddM+VlHQX46x63vwxpl6+/+bSTg8tG ndfA== 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=q3rtNB2ALn6ZgZkci91uIi9VkirFRavBNysHIEsFMf4=; b=J7Qm0tUw5s30LSrgjGU3uekRaSQno9AvC3HZwxSuMzhlMkUwvc8WyFas1r+BAg1iqC TT5fIkA7nHC9SBVk8VlP2lPezsJIiIpxA0m7uy7WNajkQrxljAdAUgBboUZfjUIhSGmg 2ugKe63auLdfRhZhqc45khg+AuWeltMBCGu0DTBlN/HKFFKtsgl2WgM49MDAqJlMoosV y6UWlZppFZdBdTFINJ92Su0CgHKdb1rh5aza+GAO7giWpV4IweWBjofS5dqWLSWdJTqb JCaXPOrHs9r4h1xrKSYYF9Bs3zypZ3de3dWBbZl5awcTr3iUoIk5iJbJK7EBUQFoyEDL dxgQ== 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 s5-20020a170902ea0500b0017d8a86e524si6384749plg.506.2022.11.21.19.43.20; Mon, 21 Nov 2022 19:43: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 S231717AbiKVDcy (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Mon, 21 Nov 2022 22:32:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229516AbiKVDcw (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 21 Nov 2022 22:32:52 -0500 Received: from cstnet.cn (smtp84.cstnet.cn [159.226.251.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78B0A192AF for <linux-kernel@vger.kernel.org>; Mon, 21 Nov 2022 19:32:49 -0800 (PST) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-05 (Coremail) with SMTP id zQCowAAXHu7dQnxj2HOwAA--.11930S2; Tue, 22 Nov 2022 11:32:45 +0800 (CST) From: Jiasheng Jiang <jiasheng@iscas.ac.cn> To: jdmason@kudzu.us, dave.jiang@intel.com, allenbh@gmail.com, error27@gmail.com Cc: ntb@lists.linux.dev, linux-kernel@vger.kernel.org, Jiasheng Jiang <jiasheng@iscas.ac.cn> Subject: [PATCH] NTB: ntb_tool: Add check for devm_kcalloc Date: Tue, 22 Nov 2022 11:32:44 +0800 Message-Id: <20221122033244.5777-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowAAXHu7dQnxj2HOwAA--.11930S2 X-Coremail-Antispam: 1UD129KBjvdXoW7Jw4DurWfJryxGFy8CFW8tFb_yoWfZFc_CF y2qrsrGr45Cw45K3Z2yr4xZrWxA3WDuFZ7W3y8tan8urWDCw1xXry8urZxCa1fua48GFZr G34jyry0yF1xujkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsxFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_ Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkF7I0En4kS14v26r1q 6r43MxkIecxEwVAFwVW8GwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0x ZFpf9x0JUk5rxUUUUU= 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?1750166261485402413?= X-GMAIL-MSGID: =?utf-8?q?1750166261485402413?= |
Series |
NTB: ntb_tool: Add check for devm_kcalloc
|
|
Commit Message
Jiasheng Jiang
Nov. 22, 2022, 3:32 a.m. UTC
As the devm_kcalloc may return NULL pointer,
it should be better to add check for the return
value, as same as the others.
Fixes: 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/ntb/test/ntb_tool.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Tue, Nov 22, 2022 at 11:32:44AM +0800, Jiasheng Jiang wrote: > As the devm_kcalloc may return NULL pointer, > it should be better to add check for the return > value, as same as the others. > > Fixes: 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support") > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Right. Thanks! Reviewed-by: Serge Semin <fancer.lancer@gmail.com> -Sergey > --- > drivers/ntb/test/ntb_tool.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c > index 5ee0afa621a9..eeeb4b1c97d2 100644 > --- a/drivers/ntb/test/ntb_tool.c > +++ b/drivers/ntb/test/ntb_tool.c > @@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) > tc->peers[pidx].outmws = > devm_kcalloc(&tc->ntb->dev, tc->peers[pidx].outmw_cnt, > sizeof(*tc->peers[pidx].outmws), GFP_KERNEL); > + if (tc->peers[pidx].outmws == NULL) > + return -ENOMEM; > > for (widx = 0; widx < tc->peers[pidx].outmw_cnt; widx++) { > tc->peers[pidx].outmws[widx].pidx = pidx; > -- > 2.25.1 > >
On 11/21/2022 8:32 PM, Jiasheng Jiang wrote: > As the devm_kcalloc may return NULL pointer, > it should be better to add check for the return > value, as same as the others. > > Fixes: 7f46c8b3a552 ("NTB: ntb_tool: Add full multi-port NTB API support") > Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: Dave Jiang <dave.jiang@intel.com> > --- > drivers/ntb/test/ntb_tool.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c > index 5ee0afa621a9..eeeb4b1c97d2 100644 > --- a/drivers/ntb/test/ntb_tool.c > +++ b/drivers/ntb/test/ntb_tool.c > @@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) > tc->peers[pidx].outmws = > devm_kcalloc(&tc->ntb->dev, tc->peers[pidx].outmw_cnt, > sizeof(*tc->peers[pidx].outmws), GFP_KERNEL); > + if (tc->peers[pidx].outmws == NULL) > + return -ENOMEM; > > for (widx = 0; widx < tc->peers[pidx].outmw_cnt; widx++) { > tc->peers[pidx].outmws[widx].pidx = pidx;
diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c index 5ee0afa621a9..eeeb4b1c97d2 100644 --- a/drivers/ntb/test/ntb_tool.c +++ b/drivers/ntb/test/ntb_tool.c @@ -998,6 +998,8 @@ static int tool_init_mws(struct tool_ctx *tc) tc->peers[pidx].outmws = devm_kcalloc(&tc->ntb->dev, tc->peers[pidx].outmw_cnt, sizeof(*tc->peers[pidx].outmws), GFP_KERNEL); + if (tc->peers[pidx].outmws == NULL) + return -ENOMEM; for (widx = 0; widx < tc->peers[pidx].outmw_cnt; widx++) { tc->peers[pidx].outmws[widx].pidx = pidx;