From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,vireshk@kernel.org,sboyd@kernel.org,nm@ti.com,lukas.bulwahn@gmail.com,krzk@kernel.org,joe@perches.com,james.bottomley@HansenPartnership.com,geert@linux-m68k.org,dwaipayanray1@gmail.com,david.hunter.linux@gmail.com,dan.j.williams@intel.com,dan.carpenter@linaro.org,corbet@lwn.net,apw@canonical.com,allyheev@gmail.com,akpm@linux-foundation.org
Subject: [merged mm-nonmm-stable] checkpatch-add-uninitialized-pointer-with-__free-attribute-check.patch removed from -mm tree
Date: Tue, 09 Dec 2025 11:33:25 -0800 [thread overview]
Message-ID: <20251209193326.2DDFEC4CEF5@smtp.kernel.org> (raw)
The quilt patch titled
Subject: checkpatch: add uninitialized pointer with __free attribute check
has been removed from the -mm tree. Its filename was
checkpatch-add-uninitialized-pointer-with-__free-attribute-check.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Ally Heev <allyheev@gmail.com>
Subject: checkpatch: add uninitialized pointer with __free attribute check
Date: Wed, 03 Dec 2025 20:58:49 +0530
Uinitialized pointers with __free attribute can cause undefined behavior
as the memory randomly assigned to the pointer is freed automatically when
the pointer goes out of scope. add check in checkpatch to detect such
issues.
Link: https://lkml.kernel.org/r/20251203-aheev-checkpatch-uninitialized-free-v7-1-841e3b31d8f3@gmail.com
Signed-off-by: Ally Heev <allyheev@gmail.com>
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/all/8a4c0b43-cf63-400d-b33d-d9c447b7e0b9@suswa.mountain/
Link: https://lore.kernel.org/all/58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com/
Acked-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Acked-by: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: David Hunter <david.hunter.linux@gmail.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: James Bottomley <james.bottomley@HansenPartnership.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Menon, Nishanth <nm@ti.com>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Viresh Kumar <vireshk@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
Documentation/dev-tools/checkpatch.rst | 23 +++++++++++++++++++++++
scripts/checkpatch.pl | 6 ++++++
2 files changed, 29 insertions(+)
--- a/Documentation/dev-tools/checkpatch.rst~checkpatch-add-uninitialized-pointer-with-__free-attribute-check
+++ a/Documentation/dev-tools/checkpatch.rst
@@ -1009,6 +1009,29 @@ Functions and Variables
return bar;
+ **UNINITIALIZED_PTR_WITH_FREE**
+ Pointers with __free attribute should be declared at the place of use
+ and initialized (see include/linux/cleanup.h). In this case
+ declarations at the top of the function rule can be relaxed. Not doing
+ so may lead to undefined behavior as the memory assigned (garbage,
+ in case not initialized) to the pointer is freed automatically when
+ the pointer goes out of scope.
+
+ Also see: https://lore.kernel.org/lkml/58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com/
+
+ Example::
+
+ type var __free(free_func);
+ ... // var not used, but, in future someone might add a return here
+ var = malloc(var_size);
+ ...
+
+ should be initialized as::
+
+ ...
+ type var __free(free_func) = malloc(var_size);
+ ...
+
Permissions
-----------
--- a/scripts/checkpatch.pl~checkpatch-add-uninitialized-pointer-with-__free-attribute-check
+++ a/scripts/checkpatch.pl
@@ -7732,6 +7732,12 @@ sub process {
ERROR("MISSING_SENTINEL", "missing sentinel in ID array\n" . "$here\n$stat\n");
}
}
+
+# check for uninitialized pointers with __free attribute
+ while ($line =~ /\*\s*($Ident)\s+__free\s*\(\s*$Ident\s*\)\s*[,;]/g) {
+ ERROR("UNINITIALIZED_PTR_WITH_FREE",
+ "pointer '$1' with __free attribute should be initialized\n" . $herecurr);
+ }
}
# If we have no input at all, then there is nothing to report on
_
Patches currently in -mm which might be from allyheev@gmail.com are
reply other threads:[~2025-12-09 19:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251209193326.2DDFEC4CEF5@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=allyheev@gmail.com \
--cc=apw@canonical.com \
--cc=corbet@lwn.net \
--cc=dan.carpenter@linaro.org \
--cc=dan.j.williams@intel.com \
--cc=david.hunter.linux@gmail.com \
--cc=dwaipayanray1@gmail.com \
--cc=geert@linux-m68k.org \
--cc=james.bottomley@HansenPartnership.com \
--cc=joe@perches.com \
--cc=krzk@kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=mm-commits@vger.kernel.org \
--cc=nm@ti.com \
--cc=sboyd@kernel.org \
--cc=vireshk@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.