[PATCH 1/2] firmware: arm_scmi: Fix confusing cleanup.h syntax
Krzysztof Kozlowski
krzysztof.kozlowski at oss.qualcomm.com
Sun Dec 7 18:09:08 PST 2025
Initializing automatic __free variables to NULL without need (e.g.
branches with different allocations), followed by actual allocation is
in contrary to explicit coding rules guiding cleanup.h:
"Given that the "__free(...) = NULL" pattern for variables defined at
the top of the function poses this potential interdependency problem the
recommendation is to always define and assign variables in one statement
and not group variable definitions at the top of the function when
__free() is used."
Code does not have a bug, but is less readable and uses discouraged
coding practice, so fix that by moving declaration to the place of
assignment.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at oss.qualcomm.com>
---
drivers/firmware/arm_scmi/quirks.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/quirks.c b/drivers/firmware/arm_scmi/quirks.c
index 03848283c2a0..4fb09bb8c6b3 100644
--- a/drivers/firmware/arm_scmi/quirks.c
+++ b/drivers/firmware/arm_scmi/quirks.c
@@ -218,7 +218,7 @@ static unsigned int scmi_quirk_signature(const char *vend, const char *sub_vend)
static int scmi_quirk_range_parse(struct scmi_quirk *quirk)
{
- const char *last, *first __free(kfree) = NULL;
+ const char *last;
size_t len;
char *sep;
int ret;
@@ -229,7 +229,8 @@ static int scmi_quirk_range_parse(struct scmi_quirk *quirk)
if (!len)
return 0;
- first = kmemdup(quirk->impl_ver_range, len + 1, GFP_KERNEL);
+ const char *first __free(kfree) = kmemdup(quirk->impl_ver_range, len + 1,
+ GFP_KERNEL);
if (!first)
return -ENOMEM;
--
2.51.0
More information about the linux-arm-kernel
mailing list