checkpatch-add-uninitialized-pointer-with-__free-attribute-check.patch removed from -mm tree
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 <[email protected]>
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.
---
Documentation/dev-tools/checkpatch.rst | 23 +++++++++++++++++++++++ scripts/checkpatch.pl | 6 ++++++ 2 files changed, 29 insertions(+)
Documentation/dev-tools/checkpatch.rst renamed from Documentation/dev-tools/checkpatch.rst~checkpatch-add-uninitialized-pointer-with-__free-attribute-check +23 -0
@@ -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 -----------
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-add-uninitialized-pointer-with-__free-attribute-check +6 -0
@@ -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 [email protected] are