lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250625102047.483300-1-yuehaibing@huawei.com>
Date: Wed, 25 Jun 2025 18:20:47 +0800
From: Yue Haibing <yuehaibing@...wei.com>
To: <saeedm@...dia.com>, <leon@...nel.org>, <tariqt@...dia.com>,
	<andrew+netdev@...n.ch>, <davem@...emloft.net>, <edumazet@...gle.com>,
	<kuba@...nel.org>, <pabeni@...hat.com>, <yuehaibing@...wei.com>
CC: <netdev@...r.kernel.org>, <linux-rdma@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: [PATCH net-next] net/mlx5e: Cleanup error handle in mlx5e_tc_sample_init()

post_act is initialized in mlx5e_tc_post_act_init(), which never return
NULL. And if it is invalid, no need to alloc tc_psample mem.

Signed-off-by: Yue Haibing <yuehaibing@...wei.com>
---
 .../ethernet/mellanox/mlx5/core/en/tc/sample.c   | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
index 5db239cae814..1b083afbe1bc 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
@@ -619,26 +619,30 @@ mlx5e_tc_sample_init(struct mlx5_eswitch *esw, struct mlx5e_post_act *post_act)
 	struct mlx5e_tc_psample *tc_psample;
 	int err;
 
-	tc_psample = kzalloc(sizeof(*tc_psample), GFP_KERNEL);
-	if (!tc_psample)
-		return ERR_PTR(-ENOMEM);
-	if (IS_ERR_OR_NULL(post_act)) {
+	if (IS_ERR(post_act)) {
 		err = PTR_ERR(post_act);
 		goto err_post_act;
 	}
+
+	tc_psample = kzalloc(sizeof(*tc_psample), GFP_KERNEL);
+	if (!tc_psample) {
+		err = -ENOMEM;
+		goto err_post_act;
+	}
 	tc_psample->post_act = post_act;
 	tc_psample->esw = esw;
 	err = sampler_termtbl_create(tc_psample);
 	if (err)
-		goto err_post_act;
+		goto err_create;
 
 	mutex_init(&tc_psample->ht_lock);
 	mutex_init(&tc_psample->restore_lock);
 
 	return tc_psample;
 
-err_post_act:
+err_create:
 	kfree(tc_psample);
+err_post_act:
 	return ERR_PTR(err);
 }
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ