Devicetree
 help / color / mirror / Atom feed
* [PATCH] of: unittest: Fix overlay node reference leak in of_notify()
@ 2026-09-17 12:44 Wentao Liang
  2026-09-17 12:52 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 12:44 UTC (permalink / raw)
  To: devicetree
  Cc: frowand.list, linux-kernel, robh, saravanak, Wentao Liang, stable

of_notify() takes a reference on nd->overlay but only drops it in the
default branch of the action switch. The PRE_APPLY, POST_APPLY,
PRE_REMOVE and POST_REMOVE branches return without dropping it, so the
reference is leaked on every notification. Move the of_node_put() to the
common exit path.

Fixes: 992b0dc5c38a ("of: overlay: unittest: add tests for overlay notifiers")
Cc: stable@vger.kernel.org
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 c4d4c10ceaa2..5259c45e355d 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3429,11 +3429,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] 2+ messages in thread

end of thread, other threads:[~2026-09-17 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 12:44 [PATCH] of: unittest: Fix overlay node reference leak in of_notify() Wentao Liang
2026-09-17 12:52 ` sashiko-bot

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