Subject: Re: [PATCH net-next v2 02/11] net: make netdev_lock() protect netdev->reg_state

From: Jakub Kicinski <[email-masked]>
Date: Wed, 15 Jan 2025 06:18:20 -0800

On Wed, 15 Jan 2025 17:30:23 +0900 Kuniyuki Iwashima wrote:
> > @@ -10668,7 +10668,9 @@ int register_netdevice(struct net_device *dev)
> >  
> >  	ret = netdev_register_kobject(dev);
> >  
> > +	netdev_lock(dev);
> >  	WRITE_ONCE(dev->reg_state, ret ? NETREG_UNREGISTERED : NETREG_REGISTERED);
> > +	netdev_unlock(dev);  
> 
> Do we need the lock before list_netdevice() ?

Fair point, we don't. I couldn't decide whether it's more logical 
to skip the locking since device is not listed, or lock it, just
because we say that @reg_state is supposed to be write protected.