Subject: Re: atl1c drivers run 'napi/eth%d-385' named threads with unsubstituted %d

From: Andrew Lunn <[email-masked]>
Date: Sat, 22 Jan 2022 02:53:42 +0100

> > So please give this a try. I've not even compile tested it...
> > 
> > iff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> > index da595242bc13..983a52f77bda 100644
> > --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> > +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> > @@ -2706,6 +2706,10 @@ static int atl1c_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> >                 goto err_alloc_etherdev;
> >         }
> >  
> > +       err = dev_alloc_name(netdev, netdev->name);
> > +       if (err < 0)
> > +               goto err_init_netdev;
> > +
> >         err = atl1c_init_netdev(netdev, pdev);
> >         if (err) {
> >                 dev_err(&pdev->dev, "init netdevice failed\n");
> > 
> > If this works, i can turn it into a real patch submission.
> > 
> >    Andrew
> 
> 
> This may not work right because probe is not called with RTNL.
> And the alloc_name is using RTNL to prevent two devices from
> getting the same name.

Oh, yes. I looked at some of the users. And some do take rtnl before
calling it. And some don't!

Looking at register_netdev(), it seems we need something like:

	if (rtnl_lock_killable()) {
	       err = -EINTR;
	       goto err_init_netdev;
	}
	err = dev_alloc_name(netdev, netdev->name);
	rtnl_unlock();
	if (err < 0)
		goto err_init_netdev;

It might also be a good idea to put a ASSERT_RTNL() in
__dev_alloc_name() to catch any driver doing this wrong.

	   Andrew