[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240311111020.24f46bbc@kernel.org>
Date: Mon, 11 Mar 2024 11:10:20 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Shay Drory <shayd@...dia.com>
Cc: <netdev@...r.kernel.org>, <pabeni@...hat.com>, <davem@...emloft.net>,
<edumazet@...gle.com>, Jiri Pirko <jiri@...dia.com>
Subject: Re: [PATCH net] devlink: Fix devlink parallel commands processing
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
Powered by blists - more mailing lists