netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Shay Drory <shayd@nvidia.com>
Cc: <netdev@vger.kernel.org>, <pabeni@redhat.com>,
	<davem@davemloft.net>, <edumazet@google.com>,
	Jiri Pirko <jiri@nvidia.com>
Subject: Re: [PATCH net] devlink: Fix devlink parallel commands processing
Date: Mon, 11 Mar 2024 11:10:20 -0700	[thread overview]
Message-ID: <20240311111020.24f46bbc@kernel.org> (raw)
In-Reply-To: <20240311085726.273193-1-shayd@nvidia.com>

On Mon, 11 Mar 2024 10:57:26 +0200 Shay Drory wrote:
>  	devlinks_xa_for_each_registered_get(net, index, devlink) {
> -		devl_dev_lock(devlink, dev_lock);
> -		if (devl_is_registered(devlink) &&
> -		    strcmp(devlink->dev->bus->name, busname) == 0 &&
> +		if (strcmp(devlink->dev->bus->name, busname) == 0 &&
>  		    strcmp(dev_name(devlink->dev), devname) == 0)
> -			return devlink;
> -		devl_dev_unlock(devlink, dev_lock);
> +			goto found;

there's no need for a goto here:

		if (strcmp(devlink->dev->bus->name, busname) == 0 &&
		    strcmp(dev_name(devlink->dev), devname) == 0) {
			devl_dev_lock(devlink, dev_lock);
			if (devl_is_registered(devlink))
				return devlink;
			devl_dev_unlock(devlink, dev_lock);
		}

simpler, and also no change in behavior (in case some impossible
race happens and we have 2 devlinks with the same name, one already
unregistered and one registered).

>  		devlink_put(devlink);
>  	}
> +	return ERR_PTR(-ENODEV);
> +
> +found:
> +	devl_dev_lock(devlink, dev_lock);
> +	if (devl_is_registered(devlink))
> +		return devlink;
>  
> +	devl_dev_unlock(devlink, dev_lock);
> +	devlink_put(devlink);
>  	return ERR_PTR(-ENODEV);
-- 
pw-bot: cr

      reply	other threads:[~2024-03-11 18:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11  8:57 [PATCH net] devlink: Fix devlink parallel commands processing Shay Drory
2024-03-11 18:10 ` Jakub Kicinski [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=20240311111020.24f46bbc@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shayd@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;
as well as URLs for NNTP newsgroup(s).