Re: [PATCH] ath10k: allocate dummy net_device dynamically
From: Jakub Kicinski
Date: Thu Mar 21 2024 - 18:18:19 EST
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 :(
Maybe we should add a new helper to "alloc dummy netdev" which can
call alloc_netdev() with right arguments and do necessary init?
> So I'm just suggesting that instead we use kmalloc() and kfree(), which are
> matching functions, and which, like the existing code, are not subject to
> whatever is happening in alloc_netdev()/free_netdev().
>
> I don't understand your objection.
Using subsystem APIs to allocate its objects is preferable to ad hoc
kmalloc().
We're working upstream, basic alloc/free of an object should work.
Took me 5 min to realize what the problem is.