sit: proper dev_{hold|put} in ndo_[un]init methods
Subsystems (2)
PATCH 1/1 sit: proper dev_{hold|put} in ndo_[un]init methods
From: Eric Dumazet <[email protected]>
After adopting CONFIG_PCPU_DEV_REFCNT=n option, syzbot was able to trigger a warning [1]
Issue here is that:
- all dev_put() should be paired with a corresponding prior dev_hold().
- A driver doing a dev_put() in its ndo_uninit() MUST also do a dev_hold() in its ndo_init(), only when ndo_init() is returning 0.
Otherwise, register_netdevice() would call ndo_uninit() in its error path and release a refcount too soon.
--- net/ipv6/sit.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/ipv6/sit.c +1 -3
@@ -218,8 +218,6 @@ static int ipip6_tunnel_create(struct net_device *dev)ipip6_tunnel_clone_6rd (dev, sitn); -dev_hold (dev); -ipip6_tunnel_link (sitn, t);return 0 ;
@@ -1456,7 +1454,7 @@ static int ipip6_tunnel_init(struct net_device *dev) dev->tstats =NULL ;return err; } - +dev_hold (dev);return 0 ; }
Signature · 1 line
2.31.0.291.g576ba9dcdaf-goog
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Mon, 29 Mar 2021 12:25:22 -0700 you wrote:
From: Eric Dumazet <[email protected]>
After adopting
CONFIG_PCPU_DEV_REFCNT=noption, syzbot was able to trigger a warning [1]Issue here is that:
[...]
Here is the summary with links:
- [net-next] sit: proper dev_{hold|put} in ndo_[un]init methods
https://git.kernel.org/netdev/net-next/c/6289a98f0817
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html