Linux clock framework development
 help / color / mirror / Atom feed
* [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

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