netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Yuan Can <yuancan@huawei.com>
Cc: <idosch@nvidia.com>, <petrm@nvidia.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] mlxsw: spectrum_router: fix xa_store() error checking
Date: Tue, 15 Oct 2024 10:06:19 +0200	[thread overview]
Message-ID: <8734kxix77.fsf@nvidia.com> (raw)
In-Reply-To: <20241015063651.8610-1-yuancan@huawei.com>


Yuan Can <yuancan@huawei.com> writes:

> It is meant to use xa_err() to extract the error encoded in the return
> value of xa_store().
>
> Fixes: 44c2fbebe18a ("mlxsw: spectrum_router: Share nexthop counters in resilient groups")
> Signed-off-by: Yuan Can <yuancan@huawei.com>

Reviewed-by: Petr Machata <petrm@nvidia.com>

What's the consequence of using IS_ERR()/PTR_ERR() vs. xa_err()? From
the documentation it looks like IS_ERR() might interpret some valid
pointers as errors[0]. Which would then show as leaks, because we bail
out early and never clean up?

I.e. should this aim at net rather than net-next? It looks like it's not
just semantics, but has actual observable impact.

[0] "The XArray does not support storing IS_ERR() pointers as some
    conflict with value entries or internal entries."

> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> index 800dfb64ec83..7d6d859cef3f 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> @@ -3197,7 +3197,6 @@ mlxsw_sp_nexthop_sh_counter_get(struct mlxsw_sp *mlxsw_sp,
>  {
>  	struct mlxsw_sp_nexthop_group *nh_grp = nh->nhgi->nh_grp;
>  	struct mlxsw_sp_nexthop_counter *nhct;
> -	void *ptr;
>  	int err;
>  
>  	nhct = xa_load(&nh_grp->nhgi->nexthop_counters, nh->id);
> @@ -3210,12 +3209,10 @@ mlxsw_sp_nexthop_sh_counter_get(struct mlxsw_sp *mlxsw_sp,
>  	if (IS_ERR(nhct))
>  		return nhct;
>  
> -	ptr = xa_store(&nh_grp->nhgi->nexthop_counters, nh->id, nhct,
> -		       GFP_KERNEL);
> -	if (IS_ERR(ptr)) {
> -		err = PTR_ERR(ptr);
> +	err = xa_err(xa_store(&nh_grp->nhgi->nexthop_counters, nh->id, nhct,
> +			      GFP_KERNEL));
> +	if (err)
>  		goto err_store;
> -	}

  reply	other threads:[~2024-10-15  8:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-15  6:36 [PATCH net-next] mlxsw: spectrum_router: fix xa_store() error checking Yuan Can
2024-10-15  8:06 ` Petr Machata [this message]
2024-10-16  2:19   ` Yuan Can
2024-10-16  9:41     ` Petr Machata
2024-10-16 12:38     ` Przemek Kitszel

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=8734kxix77.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yuancan@huawei.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;
as well as URLs for NNTP newsgroup(s).