summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2021-03-29 12:25:22 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-22 10:38:30 +0200
commit1316d11c8730dcff7f8e59127be62868639928d7 (patch)
tree550f1d43aac6be8f85a28221ae77ab4fbe506984
parent40027f114cc1feaee2f7224567e5466ba00edb91 (diff)
downloadlinux-stable-1316d11c8730dcff7f8e59127be62868639928d7.tar.gz
linux-stable-1316d11c8730dcff7f8e59127be62868639928d7.tar.bz2
linux-stable-1316d11c8730dcff7f8e59127be62868639928d7.zip
sit: proper dev_{hold|put} in ndo_[un]init methods
commit 6289a98f0817a4a457750d6345e754838eae9439 upstream. 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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/ipv6/sit.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 1ee190137da4..b1913993b321 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -209,8 +209,6 @@ static int ipip6_tunnel_create(struct net_device *dev)
dev->rtnl_link_ops = &sit_link_ops;
- dev_hold(dev);
-
ipip6_tunnel_link(sitn, t);
return 0;
@@ -1399,7 +1397,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
dev->tstats = NULL;
return err;
}
-
+ dev_hold(dev);
return 0;
}