From: Jamie Bainbridge <jamie.bainbridge@gmail.com>
To: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Jamie Bainbridge <jamie.bainbridge@gmail.com>,
David Decotigny <decot@google.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH net 2/4] net-sysfs: check device is present when showing duplex
Date: Wed, 24 Jul 2024 11:46:51 +1000 [thread overview]
Message-ID: <f0d97fe4c339798a79265dfad811bb68f4f2bc63.1721784184.git.jamie.bainbridge@gmail.com> (raw)
In-Reply-To: <cover.1721784184.git.jamie.bainbridge@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2024-07-24 1:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1721784184.git.jamie.bainbridge@gmail.com>
2024-07-24 1:46 ` [PATCH net 1/4] net-sysfs: check device is present when showing carrier Jamie Bainbridge
2024-07-24 9:35 ` Johannes Berg
2024-07-24 9:41 ` Johannes Berg
2024-07-24 22:54 ` Jamie Bainbridge
2024-07-25 2:22 ` Shigeru Yoshida
2024-07-24 1:46 ` Jamie Bainbridge [this message]
2024-07-24 1:46 ` [PATCH net 3/4] net-sysfs: check device is present when showing testing Jamie Bainbridge
2024-07-24 10:35 ` Andrew Lunn
2024-07-24 1:46 ` [PATCH net 4/4] net-sysfs: check device is present when showing dormant Jamie Bainbridge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0d97fe4c339798a79265dfad811bb68f4f2bc63.1721784184.git.jamie.bainbridge@gmail.com \
--to=jamie.bainbridge@gmail.com \
--cc=davem@davemloft.net \
--cc=decot@google.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®