Skip to content

Commit

Permalink
net: fix the missing unlock for detached devices
Browse files Browse the repository at this point in the history
The combined condition was left as is when we converted
from __dev_get_by_index() to netdev_get_by_index_lock().
There was no need to undo anything with the former, for
the latter we need an unlock.

Fixes: 1d22d30 ("net: drop rtnl_lock for queue_mgmt operations")
Reviewed-by: Mina Almasry <almasrymina@google.com>
Link: https://patch.msgid.link/20250418015317.1954107-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Apr 22, 2025
1 parent b9a4c74 commit d3153c3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/core/netdev-genl.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,14 +861,17 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)

mutex_lock(&priv->lock);

err = 0;
netdev = netdev_get_by_index_lock(genl_info_net(info), ifindex);
if (!netdev || !netif_device_present(netdev)) {
if (!netdev) {
err = -ENODEV;
goto err_unlock_sock;
}

if (!netdev_need_ops_lock(netdev)) {
if (!netif_device_present(netdev))
err = -ENODEV;
else if (!netdev_need_ops_lock(netdev))
err = -EOPNOTSUPP;
if (err) {
NL_SET_BAD_ATTR(info->extack,
info->attrs[NETDEV_A_DEV_IFINDEX]);
goto err_unlock;
Expand Down

0 comments on commit d3153c3

Please sign in to comment.