Re: [PATCH net v3 1/2] smsc911x: only update stats when interface is up

From: Jakub Kicinski
Date: Thu Mar 23 2023 - 14:39:52 EST


On Wed, 22 Mar 2023 08:19:58 +0100 Wolfram Sang wrote:
> - smsc911x_tx_update_txcounters(dev);
> - dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
> +
> + if (netif_running(dev)) {
> + smsc911x_tx_update_txcounters(dev);
> + dev->stats.rx_dropped += smsc911x_reg_read(pdata, RX_DROP);
> + }

Same problem as on the renesas patch, netif_running() can return true
before ndo->open() is called. And stats can be read with just the RCU
lock (via procfs).

Maybe we should add a false-negative version of netif_running() ?
__LINK_STATE_START*ED* ?