soc: sunxi: sram: Release node references when claims fail

Message ID 20261112023126.118228-1-zhujun2@cmss.chinamobile.com (mailing list archive)
State New
Headers
Series soc: sunxi: sram: Release node references when claims fail |

Commit Message

Zhu Jun Nov. 12, 2026, 2:31 a.m. UTC
When claiming an SRAM region fails, sunxi_sram_claim() leaves the phandle
iteration before it can release the current node. The rollback loop also
parses each previously claimed region without releasing the returned
node reference.

Put the iterator's current node before rollback and release each node
after undoing its claim.

OpenAI Codex assisted with analysis and patch preparation.

Fixes: be99eb936b4f ("soc: sunxi: sram: Support claiming multiple regions per device")
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 drivers/soc/sunxi/sunxi_sram.c | 2 ++
 1 file changed, 2 insertions(+)
  

Patch

diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
index 2ccaeacf8c70..4667661b2003 100644
--- a/drivers/soc/sunxi/sunxi_sram.c
+++ b/drivers/soc/sunxi/sunxi_sram.c
@@ -294,12 +294,14 @@  int sunxi_sram_claim(struct device *dev)
 	return 0;
 
 err:
+	of_node_put(it.node);
 	while (count--) {
 		struct of_phandle_args args;
 
 		of_parse_phandle_with_fixed_args(dev->of_node, SUNXI_SRAM_PROP,
 						 SUNXI_SRAM_CELLS, count, &args);
 		sunxi_sram_release_one(args.np, args.args[0]);
+		of_node_put(args.np);
 	}
 
 	return err;