[PATCH] of: unittest: fix node reference leak in of_notify()

From: Wentao Liang

Date: Tue Nov 03 2026 - 06:35:16 EST


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@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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