* [PATCH] clk: keystone: sci-clk: Release nodes while scanning DT clocks
@ 2026-11-12 2:31 Zhu Jun
2026-11-12 2:37 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2026-11-12 2:31 UTC (permalink / raw)
To: kristo
Cc: nm, ssantosh, sboyd, bmasney+clk, jbrunet+clk, linux-arm-kernel,
linux-kernel, linux-clk, Zhu Jun
ti_sci_scan_clocks_from_dt() parses clock phandles without releasing the
provider node references. Allocation failures also leave the current
consumer node referenced by the outer device tree walk.
Give each parsed provider node scoped cleanup, and release the consumer
node when returning early from the scan.
OpenAI Codex assisted with analysis and patch preparation.
Fixes: 8e48b33f9def ("clk: keystone: sci-clk: probe clocks from DT instead of firmware")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
drivers/clk/keystone/sci-clk.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
index 967f77900358..433bdca8ac83 100644
--- a/drivers/clk/keystone/sci-clk.c
+++ b/drivers/clk/keystone/sci-clk.c
@@ -541,7 +541,7 @@ static int _cmp_sci_clk_list(void *priv, const struct list_head *a,
static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
{
struct device *dev = provider->dev;
- struct device_node *np = NULL;
+ struct device_node *np __free(device_node) = NULL;
int ret;
int index;
struct of_phandle_args args;
@@ -573,13 +573,16 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
index = 0;
do {
+ struct device_node *clk_node __free(device_node) = NULL;
+
ret = of_parse_phandle_with_args(np, *clk_name,
"#clock-cells", index,
&args);
if (ret)
break;
- if (args.args_count == 2 && args.np == dev->of_node) {
+ clk_node = args.np;
+ if (args.args_count == 2 && clk_node == dev->of_node) {
sci_clk = devm_kzalloc_obj(dev, *sci_clk);
if (!sci_clk)
return -ENOMEM;
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] clk: keystone: sci-clk: Release nodes while scanning DT clocks
2026-11-12 2:31 [PATCH] clk: keystone: sci-clk: Release nodes while scanning DT clocks Zhu Jun
@ 2026-11-12 2:37 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-12 2:37 UTC (permalink / raw)
To: Zhu Jun; +Cc: linux-clk
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] clk: keystone: sci-clk: split __free() definition in
ti_sci_scan_clocks_from_dt()
--
commit f771030e1cdc7fd996c4caa11e1e8cac88d5ff99
Author: Zhu Jun <zhujun2@cmss.chinamobile.com>
clk: keystone: sci-clk: Release nodes while scanning DT clocks
This commit adds __free(device_node) annotations in
ti_sci_scan_clocks_from_dt() to release device_node references obtained
while scanning the device tree.
> diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c
> index 967f779003587..433bdca8ac836 100644
> --- a/drivers/clk/keystone/sci-clk.c
> +++ b/drivers/clk/keystone/sci-clk.c
[ ... ]
> @@ -573,13 +573,16 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider)
> index = 0;
>
> do {
> + struct device_node *clk_node __free(device_node) = NULL;
> +
> ret = of_parse_phandle_with_args(np, *clk_name,
> "#clock-cells", index,
> &args);
> if (ret)
> break;
>
> - if (args.args_count == 2 && args.np == dev->of_node) {
> + clk_node = args.np;
> + if (args.args_count == 2 && clk_node == dev->of_node) {
[Severity: Low]
This isn't a bug, but cleanup.h recommends defining and initializing
__free() variables in a single statement rather than initializing to NULL
and assigning later when the scope allows it. Since the error check on
ret breaks out of the loop before clk_node is used, clk_node can be
defined directly at the assignment:
struct device_node *clk_node __free(device_node) = args.np;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112023137.118241-1-zhujun2@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-12 2:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 2:31 [PATCH] clk: keystone: sci-clk: Release nodes while scanning DT clocks Zhu Jun
2026-11-12 2:37 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox