提交 49580735 编写于 作者: E Eric Dumazet 提交者: Yang Yingliang

sit: proper dev_{hold|put} in ndo_[un]init methods

stable inclusion
from linux-4.19.191
commit 01cc9ab6fdf1ddb0a5355196557b95819788f9bb

--------------------------------

commit 6289a98f 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: 919067cc ("net: add CONFIG_PCPU_DEV_REFCNT")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Reported-by: Nsyzbot <syzkaller@googlegroups.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 1676a202
...@@ -215,8 +215,6 @@ static int ipip6_tunnel_create(struct net_device *dev) ...@@ -215,8 +215,6 @@ static int ipip6_tunnel_create(struct net_device *dev)
ipip6_tunnel_clone_6rd(dev, sitn); ipip6_tunnel_clone_6rd(dev, sitn);
dev_hold(dev);
ipip6_tunnel_link(sitn, t); ipip6_tunnel_link(sitn, t);
return 0; return 0;
...@@ -1407,7 +1405,7 @@ static int ipip6_tunnel_init(struct net_device *dev) ...@@ -1407,7 +1405,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
dev->tstats = NULL; dev->tstats = NULL;
return err; return err;
} }
dev_hold(dev);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册