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 --- 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