[<prev] [next>] [day] [month] [year] [list]
Message-Id: <f0d97fe4c339798a79265dfad811bb68f4f2bc63.1721784184.git.jamie.bainbridge@gmail.com>
Date: Wed, 24 Jul 2024 11:46:51 +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>,
David Decotigny <decot@...gle.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH net 2/4] net-sysfs: check device is present when showing duplex
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 duplex_show.
Fixes: 8ae6daca85c8 ("ethtool: Call ethtool's get/set_settings callbacks with cleaned data")
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 7fabe5afa3012ecad6551e12f478b755952933b8..3a539a2bd4d11c5f5d7b6f15a23d61439f178c3b 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -261,7 +261,7 @@ static ssize_t duplex_show(struct device *dev,
if (!rtnl_trylock())
return restart_syscall();
- if (netif_running(netdev)) {
+ if (netif_running(netdev) && netif_device_present(netdev)) {
struct ethtool_link_ksettings cmd;
if (!__ethtool_get_link_ksettings(netdev, &cmd)) {
--
2.39.2
Powered by blists - more mailing lists