Re: [PATCH net] ice: Fix freeing uninitialized pointers
From: Julia Lawall
Date: Fri Mar 22 2024 - 03:25:42 EST
On Thu, 21 Mar 2024, Jakub Kicinski wrote:
> On Thu, 21 Mar 2024 15:27:47 -0700 Jesse Brandeburg wrote:
> > The gist of it is that we should instead be using inline declarations,
> > which I also agree is a reasonable style for this. It more clearly shows
> > the __free(kfree) and the allocation (kzalloc, kcalloc, etc) on the same
> > (or virtually the same) line of code.
> >
> > I'm curious if Jakub would dislike this less? Accept?
>
> At present I find this construct unreadable.
> I may get used to it, hard to say.
>
> Also I don't see the benefit of the auto-freeing construct,
> I'd venture a guess that all the bugs it may prevent would
> have been caught by smatch. But I'm an old curmudgeon stuck
> in my ways. Feel free to experiment in Intel drivers, and we'll
> see how it works out 🤷️
In my experiments with of_node_put, there seem to be many functions where
removing the frees makes the function much more readable. But
kmalloc/kfree may be used in different contexts, where the management of
the memory is a smaller percentage of the overall code. So the tradeoffs
may be different.
julia