diff options
author | Eric Dumazet <edumazet@google.com> | 2022-03-23 03:41:47 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-03-28 09:46:44 +0300 |
commit | 572f9a0d3f3feb8bd3422e88ad71882bc034b3ff (patch) | |
tree | d46e6e5e2942c20524ef0b3cbe0228bd576dafbe /net | |
parent | 2e798814e01827871938ff172d2b2ccf1e74b355 (diff) | |
download | linux-572f9a0d3f3feb8bd3422e88ad71882bc034b3ff.tar.xz |
llc: fix netdevice reference leaks in llc_ui_bind()
commit 764f4eb6846f5475f1244767d24d25dd86528a4a upstream.
Whenever llc_ui_bind() and/or llc_ui_autobind()
took a reference on a netdevice but subsequently fail,
they must properly release their reference
or risk the infamous message from unregister_netdevice()
at device dismantle.
unregister_netdevice: waiting for eth0 to become free. Usage count = 3
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: 赵子轩 <beraphin@gmail.com>
Reported-by: Stoyan Manolov <smanolov@suse.de>
Link: https://lore.kernel.org/r/20220323004147.1990845-1-eric.dumazet@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/llc/af_llc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 0b3adf7594ff..3bf5dee00c70 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -311,6 +311,10 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) sock_reset_flag(sk, SOCK_ZAPPED); rc = 0; out: + if (rc) { + dev_put(llc->dev); + llc->dev = NULL; + } return rc; } @@ -409,6 +413,10 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) out_put: llc_sap_put(sap); out: + if (rc) { + dev_put(llc->dev); + llc->dev = NULL; + } release_sock(sk); return rc; } |