[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <6fdee098-230a-4c30-bfe8-1175fecb5dad@huawei.com>
Date: Mon, 21 Jul 2025 15:33:56 +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>
CC: <netdev@...r.kernel.org>, <linux-rdma@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next] net/mlx5e: Cleanup error handle in
mlx5e_tc_sample_init()
ping...
On 2025/6/25 18:20, Yue Haibing wrote:
> 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);
> }
>
Powered by blists - more mailing lists