llc: fix netdevice reference leaks in llc_ui_bind()
commit764f4eb684
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:1da177e4c3
("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> Signed-off-by: Fuhai Wang <fuhaiwang@tencent.com>
This commit is contained in:
parent
3e0050dfee
commit
87690358f7
|
@ -303,6 +303,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;
|
||||
}
|
||||
|
||||
|
@ -401,6 +405,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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue