[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdV+12MoAGNHC9kf==Bt0cLuJ39Fs+W61DN67sE_p-u=og@mail.gmail.com>
Date: Tue, 4 Nov 2025 14:28:54 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Ally Heev <allyheev@...il.com>
Cc: Dwaipayan Ray <dwaipayanray1@...il.com>, Lukas Bulwahn <lukas.bulwahn@...il.com>,
Joe Perches <joe@...ches.com>, Jonathan Corbet <corbet@....net>, Andy Whitcroft <apw@...onical.com>,
workflows@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, Dan Carpenter <dan.carpenter@...aro.org>,
David Hunter <david.hunter.linux@...il.com>, Shuah Khan <skhan@...uxfoundation.org>,
Viresh Kumar <vireshk@...nel.org>, Nishanth Menon <nm@...com>, Stephen Boyd <sboyd@...nel.org>,
linux-pm <linux-pm@...r.kernel.org>, dan.j.williams@...el.com
Subject: Re: [PATCH RESEND v3] checkpatch: add uninitialized pointer with
__free attribute check
Hi Ally,
On Tue, 4 Nov 2025 at 10:58, Ally Heev <allyheev@...il.com> 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 <dan.carpenter@...aro.org>
> Link: https://lore.kernel.org/all/8a4c0b43-cf63-400d-b33d-d9c447b7e0b9@suswa.mountain/
> Acked-by: Dan Williams <dan.j.williams@...el.com>
> Signed-off-by: Ally Heev <allyheev@...il.com>
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?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists