Re: [PATCH] ath10k: allocate dummy net_device dynamically
From: Breno Leitao
Date: Fri Mar 22 2024 - 10:59:08 EST
Hello Jakub,
On Thu, Mar 21, 2024 at 03:17:44PM -0700, Jakub Kicinski wrote:
> On Thu, 21 Mar 2024 15:02:39 -0700 Jeff Johnson wrote:
> > >> As suggested there we should just use kmalloc/kfree to match the existing logic.
> > >
> > > Please no. There is no magic here. alloc + free must match whether
> > > you're using magic object alloc wrapper (alloc_netdev()) or straight
> > > up kzalloc().
> >
> > Based upon the ath11k patch there must be something going on with
> > alloc_netdev()/free_netdev() that doesn't occur when these aren't used.
>
> Looks like init_dummy_netdev wipes the netdev structure clean, so I
> don't think we can use it directly as the setup function, Breno :(
Before my patch, init_dummy_netdev was being also used. The patch was
basically replacing the init_dummy_netdev by alloc_netdev() with will
call "setup(dev);" later.
- init_dummy_netdev(&irq_grp->napi_ndev);
+ irq_grp->napi_ndev = alloc_netdev(0, "dummy", NET_NAME_UNKNOWN,
+ init_dummy_netdev);
I am wondering if alloc_netdev() is messing with something instead of
init_dummy_netdev().
Also, Kalle's crash is during rmmod, and not during initialization.
getting NULL after free_netdev() is called.
> Maybe we should add a new helper to "alloc dummy netdev" which can
> call alloc_netdev() with right arguments and do necessary init?
What are the right arguments in this case?
Thanks!