Skip to content

Commit d3153c3

Browse files
committed
net: fix the missing unlock for detached devices
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b9a4c74 commit d3153c3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/core/netdev-genl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,14 +861,17 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
861861

862862
mutex_lock(&priv->lock);
863863

864+
err = 0;
864865
netdev = netdev_get_by_index_lock(genl_info_net(info), ifindex);
865-
if (!netdev || !netif_device_present(netdev)) {
866+
if (!netdev) {
866867
err = -ENODEV;
867868
goto err_unlock_sock;
868869
}
869-
870-
if (!netdev_need_ops_lock(netdev)) {
870+
if (!netif_device_present(netdev))
871+
err = -ENODEV;
872+
else if (!netdev_need_ops_lock(netdev))
871873
err = -EOPNOTSUPP;
874+
if (err) {
872875
NL_SET_BAD_ATTR(info->extack,
873876
info->attrs[NETDEV_A_DEV_IFINDEX]);
874877
goto err_unlock;

0 commit comments

Comments
 (0)