From nobody Wed Oct 8 18:24:55 2025 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2DD729ACD3; Wed, 25 Jun 2025 10:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750845811; cv=none; b=bsyPxOlqXSRfHcMuy6WXchy60CdNvySOoh5e9f7SAfCRGeCsxkmpQNLt8F969g5OT3l0K0VdAXEB+ROwSyhiYLu32KeKWezmGTZ/zsuIGnfr7JqtgwqhNOKAbRBuqFB+cqsRFQpuMBeUGxzxRbXnCqlNJvIhC5QLLruMzjcP33s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750845811; c=relaxed/simple; bh=nfWwkftoY3bVlk7D0XPjKP4CoRfg54mIhI5hMgyfgRw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=O3tCTP8gx2WO3tYdS/w/2PLagmMiktEQzAUSmF7HnjQxXH384AuXSzWo+4tJSmvcEyQGxEQSALHJPO/0Ris/i3DQ3D8aPmz2WZ/UoyFjbyCWg6sUeDypmPxxsL/mwuZK7clvcrs/+RC2mCJgrljGovZsYZRmiw7u0fDWrUE/g3I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4bRy5m5RQ7z2BdX1; Wed, 25 Jun 2025 18:01:48 +0800 (CST) Received: from dggpemf500002.china.huawei.com (unknown [7.185.36.57]) by mail.maildlp.com (Postfix) with ESMTPS id 9FCE5140279; Wed, 25 Jun 2025 18:03:25 +0800 (CST) Received: from huawei.com (10.175.124.27) by dggpemf500002.china.huawei.com (7.185.36.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 25 Jun 2025 18:03:24 +0800 From: Yue Haibing To: , , , , , , , , CC: , , Subject: [PATCH net-next] net/mlx5e: Cleanup error handle in mlx5e_tc_sample_init() Date: Wed, 25 Jun 2025 18:20:47 +0800 Message-ID: <20250625102047.483300-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To dggpemf500002.china.huawei.com (7.185.36.57) Content-Type: text/plain; charset="utf-8" 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 --- .../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/drive= rs/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; =20 - tc_psample =3D 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 =3D PTR_ERR(post_act); goto err_post_act; } + + tc_psample =3D kzalloc(sizeof(*tc_psample), GFP_KERNEL); + if (!tc_psample) { + err =3D -ENOMEM; + goto err_post_act; + } tc_psample->post_act =3D post_act; tc_psample->esw =3D esw; err =3D sampler_termtbl_create(tc_psample); if (err) - goto err_post_act; + goto err_create; =20 mutex_init(&tc_psample->ht_lock); mutex_init(&tc_psample->restore_lock); =20 return tc_psample; =20 -err_post_act: +err_create: kfree(tc_psample); +err_post_act: return ERR_PTR(err); } =20 --=20 2.34.1