On Tue, 2025-11-04 at 14:28 +0100, Geert Uytterhoeven wrote: > Hi Ally, > > On Tue, 4 Nov 2025 at 10:58, Ally Heev <[email protected]> wrote: > > uninitialized pointers with __free attribute can cause undefined > > behaviour as the memory allocated to the pointer is freed > > automatically when the pointer goes out of scope. > > add check in checkpatch to detect such issues > > > > Suggested-by: Dan Carpenter <[email protected]> > > Link: > > https://lore.kernel.org/all/[email protected]/ > > Acked-by: Dan Williams <[email protected]> > > Signed-off-by: Ally Heev <[email protected]> > > Thanks for your patch! > > > --- a/Documentation/dev-tools/checkpatch.rst > > +++ b/Documentation/dev-tools/checkpatch.rst > > @@ -1009,6 +1009,11 @@ Functions and Variables > > > > return bar; > > > > + **UNINITIALIZED_PTR_WITH_FREE** > > + Pointers with __free attribute should be initialized. Not doing so > > + may lead to undefined behavior as the memory allocated (garbage, > > + in case not initialized) to the pointer is freed automatically > > + when the pointer goes out of scope. > > I think this is misleading, and can be improved: if the pointer is > uninitialized, no memory was allocated?
yeah right. Will update in next version Regards, Ally
