[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251208020907.5476-4-krzysztof.kozlowski@oss.qualcomm.com>
Date: Mon, 8 Dec 2025 03:09:09 +0100
From: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
To: Sudeep Holla <sudeep.holla@....com>,
Cristian Marussi <cristian.marussi@....com>,
Simon Trimmer <simont@...nsource.cirrus.com>,
Charles Keepax <ckeepax@...nsource.cirrus.com>,
Richard Fitzgerald <rf@...nsource.cirrus.com>,
arm-scmi@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, patches@...nsource.cirrus.com
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@....qualcomm.com>
Subject: [PATCH 2/2] firmware: cirrus: Fix confusing cleanup.h syntax
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@....qualcomm.com>
---
drivers/firmware/cirrus/cs_dsp.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index 525ac0f0a75d..86d49dbc6fa6 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -375,13 +375,11 @@ static ssize_t cs_dsp_debugfs_string_read(struct cs_dsp *dsp,
size_t count, loff_t *ppos,
const char **pstr)
{
- const char *str __free(kfree) = NULL;
-
scoped_guard(mutex, &dsp->pwr_lock) {
if (!*pstr)
return 0;
- str = kasprintf(GFP_KERNEL, "%s\n", *pstr);
+ const char *str __free(kfree) = kasprintf(GFP_KERNEL, "%s\n", *pstr);
if (!str)
return -ENOMEM;
--
2.51.0
Powered by blists - more mailing lists