Devicetree
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: devicetree@vger.kernel.org
Cc: frowand.list@gmail.com, linux-kernel@vger.kernel.org,
	robh@kernel.org, saravanak@kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] of: unittest: Fix overlay node reference leak in of_notify()
Date: Thu, 17 Sep 2026 12:44:57 +0000	[thread overview]
Message-ID: <20260917124457.2151809-1-vulab@iscas.ac.cn> (raw)

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


             reply	other threads:[~2026-09-17 12:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 12:44 Wentao Liang [this message]
2026-09-17 12:52 ` [PATCH] of: unittest: Fix overlay node reference leak in of_notify() sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917124457.2151809-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=saravanak@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox