Skip to contentSkip to conversation

netlink: remove dev_hold() and dev_put() in __netlink_deliver_tap_skb()

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

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

PATCH 1/1 netlink: remove dev_hold() and dev_put() in __netlink_deliver_tap_skb()

__netlink_deliver_tap_skb() is called from netlink_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 (the netlink tap is unlinked and waited for via grace periods prior to device destruction).

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

---
 net/netlink/af_netlink.c | 3 ---
 1 file changed, 3 deletions(-)
net/netlink/af_netlink.c +0 -3
index 1e594baf7adf2930096f290b898d80bfa6aff4e5..6d2530e33540dce6dfc3c6ef01463a040c72812a 100644
@@ -293,8 +293,6 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb,
 	if (!net_eq(dev_net(dev), sock_net(sk)))
 		return 0;
 
-	dev_hold(dev);
-
 	if (is_vmalloc_addr(skb->head))
 		nskb = netlink_to_full_skb(skb, GFP_ATOMIC);
 	else
@@ -310,7 +308,6 @@ static int __netlink_deliver_tap_skb(struct sk_buff *skb,
 			ret = net_xmit_errno(ret);
 	}
 
-	dev_put(dev);
 	return ret;
 }
 
Signature · 1 line
2.55.0.1082.g2b9226bbc0-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 8 lines · On Mon, 21 Sep 2026 09:39:47 +0000 you wrote:

__netlink_deliver_tap_skb() is called from netlink_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 (the netlink tap is unlinked and waited for via grace periods prior to device destruction).

[...]

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

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

You are awesome, thank you!

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