Re: [PATCH net 1/4] net-sysfs: check device is present when showing carrier
From: Shigeru Yoshida
Date: Wed Jul 24 2024 - 22:22:36 EST
Hi Jamie,
On Wed, 24 Jul 2024 11:46:50 +1000, Jamie Bainbridge wrote:
> 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@xxxxxxxxx>
nit: When resubmitting your fix, there is no need for a blank line
between the Fixes and SOB tags.
Thanks,
Shigeru
> ---
> 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
>
>