Skip to content

Commit 571df33

Browse files
edumazetgregkh
authored andcommitted
llc: fix netdevice reference leaks in llc_ui_bind()
commit 764f4eb 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: 1da177e ("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>
1 parent 56dc187 commit 571df33

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

net/llc/af_llc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
311311
sock_reset_flag(sk, SOCK_ZAPPED);
312312
rc = 0;
313313
out:
314+
if (rc) {
315+
dev_put(llc->dev);
316+
llc->dev = NULL;
317+
}
314318
return rc;
315319
}
316320

@@ -409,6 +413,10 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
409413
out_put:
410414
llc_sap_put(sap);
411415
out:
416+
if (rc) {
417+
dev_put(llc->dev);
418+
llc->dev = NULL;
419+
}
412420
release_sock(sk);
413421
return rc;
414422
}

0 commit comments

Comments
 (0)