Devicetree
 help / color / mirror / Atom feed
* [PATCH] of: unittest: fix node reference leak in of_notify()
@ 2026-11-03 10:42 Wentao Liang
  2026-11-03 10:56 ` sashiko-bot
  2026-11-03 11:09 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-03 10:42 UTC (permalink / raw)
  To: Rob Herring, Saravana Kannan
  Cc: devicetree, linux-kernel, Wentao Liang, stable

of_notify() takes a reference on the overlay node passed to the
notifier, but drops it only for the unexpected action. Every regular
action returns with the reference still held, which keeps the overlay
node alive after the changeset has been removed and its memory freed.

Move the release out of the default branch so that it is performed on
all paths.

Fixes: 992b0dc5c38a ("of: overlay: unittest: add tests for overlay notifiers")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/of/unittest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index a6ac58b4d883..47da90bc0d3b 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3472,11 +3472,12 @@ static int of_notify(struct notifier_block *nb, unsigned long action,
 		break;
 
 	default:			/* should not happen */
-		of_node_put(nd->overlay);
 		ret = -EINVAL;
 		break;
 	}
 
+	of_node_put(nd->overlay);
+
 	if (ret)
 		return notifier_from_errno(ret);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-03 11:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 10:42 [PATCH] of: unittest: fix node reference leak in of_notify() Wentao Liang
2026-11-03 10:56 ` sashiko-bot
2026-11-03 11:09 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox