Skip to contentSkip to conversation

vsock: remove dev_hold() and dev_put() in __vsock_deliver_tap_skb()

PATCH Applied Eric Dumazet 4 participants 4 messages Sep 21 – Sep 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vsock: remove dev_hold() and dev_put() in __vsock_deliver_tap_skb()

__vsock_deliver_tap_skb() is called from vsock_deliver_tap() under rcu_read_lock().

dev_queue_xmit() does not require the caller to hold a device reference count, and the device lifetime is already protected by RCU.

Remove the redundant dev_hold(dev) and dev_put(dev) calls.

Cc Stefano Garzarella <[email protected]>
---
 net/vmw_vsock/af_vsock_tap.c | 4 ----
 1 file changed, 4 deletions(-)
net/vmw_vsock/af_vsock_tap.c +0 -4
index 30ee7e4fe25115cef71b43f335862a09b8c51382..7c5cdceabb2a5f7079faab243ee9de7d6bb8857c 100644
@@ -64,14 +64,10 @@ static int __vsock_deliver_tap_skb(struct sk_buff *skb,
 	struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
 
 	if (nskb) {
-		dev_hold(dev);
-
 		nskb->dev = dev;
 		ret = dev_queue_xmit(nskb);
 		if (unlikely(ret > 0))
 			ret = net_xmit_errno(ret);
-
-		dev_put(dev);
 	}
 
 	return ret;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Eric Dumazet

__vsock_deliver_tap_skb() is called from vsock_deliver_tap() under rcu_read_lock().

dev_queue_xmit() does not require the caller to hold a device reference count, and the device lifetime is already protected by RCU.

Remove the redundant dev_hold(dev) and dev_put(dev) calls.

Cc Stefano Garzarella <[email protected]>
---
 net/vmw_vsock/af_vsock_tap.c | 4 ----
 1 file changed, 4 deletions(-)
net/vmw_vsock/af_vsock_tap.c +0 -4
index 30ee7e4fe25115cef71b43f335862a09b8c51382..7c5cdceabb2a5f7079faab243ee9de7d6bb8857c 100644
@@ -64,14 +64,10 @@ static int __vsock_deliver_tap_skb(struct sk_buff *skb,
 	struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
 
 	if (nskb) {
-		dev_hold(dev);
-
 		nskb->dev = dev;
 		ret = dev_queue_xmit(nskb);
 		if (unlikely(ret > 0))
 			ret = net_xmit_errno(ret);
-
-		dev_put(dev);
 	}
 
 	return ret;
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Dumazet
Quoted 6 lines · Eric Dumazet

__vsock_deliver_tap_skb() is called from vsock_deliver_tap() under rcu_read_lock().

dev_queue_xmit() does not require the caller to hold a device reference count, and the device lifetime is already protected by RCU.

Quoted 7 lines

Remove the redundant dev_hold(dev) and dev_put(dev) calls.

Cc Stefano Garzarella <[email protected]>

---
net/vmw_vsock/af_vsock_tap.c | 4 ----

1 file changed, 4 deletions(-)

LGTM!

#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 9 lines · On Mon, 21 Sep 2026 09:42:18 +0000 you wrote:

__vsock_deliver_tap_skb() is called from vsock_deliver_tap() under rcu_read_lock().

dev_queue_xmit() does not require the caller to hold a device reference count, and the device lifetime is already protected by RCU.

Remove the redundant dev_hold(dev) and dev_put(dev) calls.

[...]

Here is the summary with links:
- [net-next] vsock: remove dev_hold() and dev_put() in __vsock_deliver_tap_skb()

    https://git.kernel.org/netdev/net-next/c/6598456d72e4

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html