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

From: Jakub Kicinski <[email-masked]>
Date: Thu, 8 Aug 2024 08:10:54 -0700

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?