Message ID | 20221108015314.17928-1-yuehaibing@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2429664wru; Mon, 7 Nov 2022 18:13:28 -0800 (PST) X-Google-Smtp-Source: AMsMyM4uVtl4dYDN1GzI3z+CjDetY+QtWy7VPfNBrS6pq0X4glcH7vW3XWZUoF5rQewyfX/Of/CX X-Received: by 2002:a17:906:d550:b0:7ad:d2f1:dba5 with SMTP id cr16-20020a170906d55000b007add2f1dba5mr42265330ejc.52.1667873608362; Mon, 07 Nov 2022 18:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667873608; cv=none; d=google.com; s=arc-20160816; b=KwwluJygM8MKtGicURqo6DWh9L2dOCAcf5dvi1/udNqQ7TNBL7jJ0UpWxJfA5vm9JG sOWBcD+QSWy00U1N4LV2WvqZ5ADixMGvp9kOTOkmzQWyeSfWgp5nLbjy+UpeuMhdel6b tAcV5kBvNHFC5UT2pqCAitjNgbMGz2C104Tu32KlZociNuxX1iCrehTOf3eTm9sHIuxD SsFJ2w3ZbPLMOhVgA6ChTorrJ3NLi+u7gaUKhk44coSl68Kzj0MhA8/FaGWN92VxwLPh 4p14AW/M/tWyVSjrbSQbSYQxP21VSyx5pr8WqhkULUVrXashRDID9cq2pIqbmT6/2Mcd XEnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Qf3up/HMZkaL/9Cq6MmBYZSAVD9zwa3Bq/o5EyCcYdk=; b=DB9ZHsvsJAfAmzES1SNZHbBhRQQGnPVzuyclHn+RjJ6Os/VpIg1RVyI4PedFyoLVmD sKKpi3iyx2siOsSh9jVli8tJh/M156k2MOnAbOAanI0O7FLy670CtWaTvthTgG4EFtGJ A+NHGoX4grxWLDXoEdqaXcVMdcekQRpxvZM+qIPx2zC/ldBVllOJWD0qpLX4Q4Wgbph+ svn57AfeGWMf7jtuCVfu3AAvmrITzJ3h8Y793YA9YttjjDFghI9/gNVjmGyIf9eb8YnZ cExK28m2jIqykeBN1E+VWtreYi/gY2uN72ospLZ/mFmBJWUot4G5frbgGxFdZ54nilWl P/NA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a056402278600b00458b9b7bb2fsi13200021ede.396.2022.11.07.18.12.54; Mon, 07 Nov 2022 18:13:28 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233520AbiKHBxa (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Mon, 7 Nov 2022 20:53:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233125AbiKHBx1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Nov 2022 20:53:27 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BA67A46B; Mon, 7 Nov 2022 17:53:26 -0800 (PST) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N5rdr6HxKzJnYH; Tue, 8 Nov 2022 09:50:24 +0800 (CST) Received: from localhost (10.174.179.215) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 8 Nov 2022 09:53:24 +0800 From: YueHaibing <yuehaibing@huawei.com> To: <saeedm@nvidia.com>, <leon@kernel.org>, <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <kliteyn@nvidia.com>, <mbloch@nvidia.com>, <valex@nvidia.com>, <erezsh@mellanox.com> CC: <netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>, YueHaibing <yuehaibing@huawei.com> Subject: [PATCH net] net/mlx5: DR, Fix uninitialized var warning Date: Tue, 8 Nov 2022 09:53:14 +0800 Message-ID: <20221108015314.17928-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.179.215] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500007.china.huawei.com (7.192.104.62) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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?1748892236947662210?= X-GMAIL-MSGID: =?utf-8?q?1748892236947662210?= |
Series |
[net] net/mlx5: DR, Fix uninitialized var warning
|
|
Commit Message
Yue Haibing
Nov. 8, 2022, 1:53 a.m. UTC
Smatch warns this:
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81
mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'.
Fix this by initializing ret with zero.
Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 08/11/2022 3:53, YueHaibing wrote: > Smatch warns this: > > drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81 > mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'. > > Fix this by initializing ret with zero. > > Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality") > Signed-off-by: YueHaibing <yuehaibing@huawei.com> > --- > drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c > index 31d443dd8386..44dea75dabde 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c > @@ -46,7 +46,7 @@ static int dr_table_set_miss_action_nic(struct mlx5dr_domain *dmn, > int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, > struct mlx5dr_action *action) > { > - int ret; > + int ret = 0; > > if (action && action->action_type != DR_ACTION_TYP_FT) > return -EOPNOTSUPP; In this case the default should be an error It will be better if ret init to -EOPNOTSUPP and if a miss action was not set and replaces ret then goto out. int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, struct mlx5dr_action *action) { - int ret; + int ret = -EOPNOTSUPP; if (action && action->action_type != DR_ACTION_TYP_FT) return -EOPNOTSUPP; @@ -67,6 +67,9 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, goto out; } + if (ret) + goto out; +
On 2022/11/10 16:20, Roi Dayan wrote: > > > On 08/11/2022 3:53, YueHaibing wrote: >> Smatch warns this: >> >> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c:81 >> mlx5dr_table_set_miss_action() error: uninitialized symbol 'ret'. >> >> Fix this by initializing ret with zero. >> >> Fixes: 7838e1725394 ("net/mlx5: DR, Expose steering table functionality") >> Signed-off-by: YueHaibing <yuehaibing@huawei.com> >> --- >> drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c >> index 31d443dd8386..44dea75dabde 100644 >> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c >> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c >> @@ -46,7 +46,7 @@ static int dr_table_set_miss_action_nic(struct mlx5dr_domain *dmn, >> int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, >> struct mlx5dr_action *action) >> { >> - int ret; >> + int ret = 0; >> >> if (action && action->action_type != DR_ACTION_TYP_FT) >> return -EOPNOTSUPP; > > > In this case the default should be an error > It will be better if ret init to -EOPNOTSUPP and if > a miss action was not set and replaces ret then goto out. Thanks for your review, will do that in v2. > > int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, > struct mlx5dr_action *action) > { > - int ret; > + int ret = -EOPNOTSUPP; > > if (action && action->action_type != DR_ACTION_TYP_FT) > return -EOPNOTSUPP; > @@ -67,6 +67,9 @@ int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, > goto out; > } > > + if (ret) > + goto out; > + > > . >
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c index 31d443dd8386..44dea75dabde 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_table.c @@ -46,7 +46,7 @@ static int dr_table_set_miss_action_nic(struct mlx5dr_domain *dmn, int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl, struct mlx5dr_action *action) { - int ret; + int ret = 0; if (action && action->action_type != DR_ACTION_TYP_FT) return -EOPNOTSUPP;