Skip to content

Commit

Permalink
net: bubble up taking netdev instance lock to callers of net_devmem_u…
Browse files Browse the repository at this point in the history
…nbind_dmabuf()

A recent commit added taking the netdev instance lock
in netdev_nl_bind_rx_doit(), but didn't remove it in
net_devmem_unbind_dmabuf() which it calls from an error path.
Always expect the callers of net_devmem_unbind_dmabuf() to
hold the lock. This is consistent with net_devmem_bind_dmabuf().

(Not so) coincidentally this also protects mp_param with the instance
lock, which the rest of this series needs.

Fixes: 1d22d30 ("net: drop rtnl_lock for queue_mgmt operations")
Reviewed-by: Mina Almasry <almasrymina@google.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250324224537.248800-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Mar 25, 2025
1 parent 5106876 commit ba6f418
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions net/core/devmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,10 @@ void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding)
rxq->mp_params.mp_priv = NULL;
rxq->mp_params.mp_ops = NULL;

netdev_lock(binding->dev);
rxq_idx = get_netdev_rx_queue_index(rxq);

err = netdev_rx_queue_restart(binding->dev, rxq_idx);
WARN_ON(err && err != -ENETDOWN);
netdev_unlock(binding->dev);
}

xa_erase(&net_devmem_dmabuf_bindings, binding->id);
Expand Down
2 changes: 2 additions & 0 deletions net/core/netdev-genl.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,9 @@ void netdev_nl_sock_priv_destroy(struct netdev_nl_sock *priv)

mutex_lock(&priv->lock);
list_for_each_entry_safe(binding, temp, &priv->bindings, list) {
netdev_lock(binding->dev);
net_devmem_unbind_dmabuf(binding);
netdev_unlock(binding->dev);
}
mutex_unlock(&priv->lock);
}
Expand Down

0 comments on commit ba6f418

Please sign in to comment.