On Tue, Mar 04, 2025 at 04:00:01PM -0800, lon...@linuxonhyperv.com wrote:
>  
> -struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 
> port_index)
> +struct net_device *mana_get_primary_netdev(struct mana_context *ac, u32 
> port_index)
>  {
>       struct net_device *ndev;
>  
> -     RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
> -                      "Taking primary netdev without holding the RCU read 
> lock");
>       if (port_index >= ac->num_ports)
>               return NULL;
>  
> +     rcu_read_lock();
> +
>       /* When mana is used in netvsc, the upper netdevice should be returned. 
> */
>       if (ac->ports[port_index]->flags & IFF_SLAVE)
>               ndev = netdev_master_upper_dev_get_rcu(ac->ports[port_index]);
>       else
>               ndev = ac->ports[port_index];
>  
> +     dev_hold(ndev);
> +     rcu_read_unlock();

That's much better, yes

Reviewed-by: Jason Gunthorpe <j...@nvidia.com>

Jason

Reply via email to