Skip to content

Commit

Permalink
llc: fix netdevice reference leaks in llc_ui_bind()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Dumazet authored and kuba-moo committed Mar 23, 2022
1 parent 2844e24 commit 764f4eb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions net/llc/af_llc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_track(llc->dev, &llc->dev_tracker);
llc->dev = NULL;
}
return rc;
}

Expand Down Expand Up @@ -408,6 +412,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_track(llc->dev, &llc->dev_tracker);
llc->dev = NULL;
}
release_sock(sk);
return rc;
}
Expand Down

0 comments on commit 764f4eb

Please sign in to comment.