[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <066463d84fa14d5f61247b95340fca12d4d3bf34.1721784184.git.jamie.bainbridge@gmail.com>
Date: Wed, 24 Jul 2024 11:46:50 +1000
From: Jamie Bainbridge <jamie.bainbridge@...il.com>
To: netdev@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: Jamie Bainbridge <jamie.bainbridge@...il.com>,
Johannes Berg <johannes.berg@...el.com>,
Jiri Pirko <jiri@...nulli.us>,
linux-kernel@...r.kernel.org
Subject: [PATCH net 1/4] net-sysfs: check device is present when showing carrier
A sysfs reader can race with a device reset or removal.
This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add
check for netdevice being present to speed_show") so add the same check
to carrier_show.
Fixes: facd15dfd691 ("net: core: synchronize link-watch when carrier is queried")
Signed-off-by: Jamie Bainbridge <jamie.bainbridge@...il.com>
---
net/core/net-sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 0e2084ce7b7572bff458ed7e02358d9258c74628..7fabe5afa3012ecad6551e12f478b755952933b8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -206,7 +206,7 @@ static ssize_t carrier_show(struct device *dev,
if (!rtnl_trylock())
return restart_syscall();
- if (netif_running(netdev)) {
+ if (netif_running(netdev) && netif_device_present(netdev)) {
/* Synchronize carrier state with link watch,
* see also rtnl_getlink().
*/
--
2.39.2
Powered by blists - more mailing lists