netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH net-next] sit: proper dev_{hold|put} in ndo_[un]init methods
@ 2021-03-31  0:05 Wong, Vee Khee
  2021-03-31  5:53 ` Eric Dumazet
  0 siblings, 1 reply; 8+ messages in thread
From: Wong, Vee Khee @ 2021-03-31  0:05 UTC (permalink / raw)
  To: eric.dumazet
  Cc: davem, edumazet, kuba, netdev, syzkaller, Ismail, Mohammad Athari

Hi all,

This patch introduced the following massive warnings printouts on a
Intel x86 Alderlake platform with STMMAC MAC and Marvell 88E2110 PHY.

[  149.674232] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  159.930310] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  170.186205] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  180.434311] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  190.682309] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  200.690176] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  210.938310] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  221.186311] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  231.442311] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  241.690186] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  251.698288] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  261.946311] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  272.194181] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  282.442311] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  292.690310] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  302.938313] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  313.186255] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  323.442329] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  333.698309] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  343.946310] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  354.202166] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  364.450190] unregister_netdevice: waiting for sit0 to become free. Usage count = 2
[  374.706314] unregister_netdevice: waiting for sit0 to become free. Usage count = 2

Is this an expected behavior?

Thanks,
VK

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH net-next] sit: proper dev_{hold|put} in ndo_[un]init methods
@ 2021-03-29 19:25 Eric Dumazet
  2021-03-29 23:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Dumazet @ 2021-03-29 19:25 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: netdev, Eric Dumazet, Eric Dumazet, syzbot

From: Eric Dumazet <edumazet@google.com>

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.

Fixes: 919067cc845f ("net: add CONFIG_PCPU_DEV_REFCNT")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
---
 net/ipv6/sit.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index b9bd2723f89a314d15c8c4ea785e84530c8acb95..488d3181aec3a5558dbefb6145400627535df761 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -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;
 }
 
-- 
2.31.0.291.g576ba9dcdaf-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-16 15:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <BYAPR11MB2870B0910C71BDDFD328B339AB7C9@BYAPR11MB2870.namprd11.prod.outlook.com>
2021-03-31  5:58 ` [PATCH net-next] sit: proper dev_{hold|put} in ndo_[un]init methods Eric Dumazet
2021-03-31  8:51   ` Wong, Vee Khee
2021-03-31  9:02     ` Eric Dumazet
2021-08-16 15:13   ` Alarig Le Lay
2021-03-31  0:05 Wong, Vee Khee
2021-03-31  5:53 ` Eric Dumazet
  -- strict thread matches above, loose matches on Subject: below --
2021-03-29 19:25 Eric Dumazet
2021-03-29 23:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).