Re: [PATCH net v4] net-sysfs: check device is present when showing duplex

From: Jamie Bainbridge
Date: Fri Aug 09 2024 - 02:14:08 EST


On Fri, 9 Aug 2024 at 01:10, Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Tue, 6 Aug 2024 16:35:27 +1000 Jamie Bainbridge wrote:
> > A sysfs reader can race with a device reset or removal, attempting to
> > read device state when the device is not actually present.
>
> True, but..
>
> > - if (netif_running(netdev)) {
> > + if (netif_running(netdev) && netif_device_present(netdev)) {
> > struct ethtool_link_ksettings cmd;
> >
> > if (!__ethtool_get_link_ksettings(netdev, &cmd)) {
>
> ..there are more callers of __ethtool_get_link_ksettings() and only
> a fraction of them have something resembling a presence check in
> their path. Can we put the check inside __ethtool_get_link_ksettings()
> itself?

No worries. iiuc that would also mean reverting commit 4224cfd7fb65
("net-sysfs: add check for netdevice being present to speed_show")
because the check is being centralised. Should I do that in the same
patch, or a separate revert patch?