[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220323004147.1990845-1-eric.dumazet@gmail.com>
Date: Tue, 22 Mar 2022 17:41:47 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: netdev <netdev@...r.kernel.org>,
Eric Dumazet <edumazet@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>,
赵子轩 <beraphin@...il.com>,
Stoyan Manolov <smanolov@...e.de>
Subject: [PATCH net-next] llc: fix netdevice reference leaks in llc_ui_bind()
From: Eric Dumazet <edumazet@...gle.com>
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@...gle.com>
Reported-by: 赵子轩 <beraphin@...il.com>
Reported-by: Stoyan Manolov <smanolov@...e.de>
---
This can be applied on net tree, depending on how network maintainers
plan to push the fix to Linus, this is obviously a stable candidate.
net/llc/af_llc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 26c00ebf4fbae4d7dc1c27d180385470fa252be0..c86256064743523f0621f21d5d023956cf1df9a0 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_track(llc->dev, &llc->dev_tracker);
+ llc->dev = NULL;
+ }
return rc;
}
@@ -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;
}
--
2.35.1.894.gb6a874cedc-goog
Powered by blists - more mailing lists