From: Yue Haibing <yuehaibing@huawei.com>
To: <saeedm@nvidia.com>, <leon@kernel.org>, <tariqt@nvidia.com>,
<andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-rdma@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] net/mlx5e: Cleanup error handle in mlx5e_tc_sample_init()
Date: Mon, 21 Jul 2025 15:33:56 +0800 [thread overview]
Message-ID: <6fdee098-230a-4c30-bfe8-1175fecb5dad@huawei.com> (raw)
In-Reply-To: <20250625102047.483300-1-yuehaibing@huawei.com>
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@huawei.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);
> }
>
prev parent reply other threads:[~2025-07-21 7:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-25 10:20 Yue Haibing
2025-07-21 7:33 ` Yue Haibing [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6fdee098-230a-4c30-bfe8-1175fecb5dad@huawei.com \
--to=yuehaibing@huawei.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®