mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miaoqian Lin <linmq006@gmail.com>
To: Miaoqian Lin <linmq006@gmail.com>,
	Nicolas Pitre <nico@fluxnic.net>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH] drivers: bus: fix device node reference leak in __cci_ace_get_port
Date: Tue,  2 Sep 2025 15:43:51 +0800	[thread overview]
Message-ID: <20250902074353.2401060-1-linmq006@gmail.com> (raw)

Add missing of_node_put() call to release
the device node reference obtained via of_parse_phandle().

Fixes: ed69bdd8fd9b ("drivers: bus: add ARM CCI support")
Cc: stable@vger.kernel.org
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/bus/arm-cci.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index b8184a903583..af180f884f1d 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -163,14 +163,18 @@ static int __cci_ace_get_port(struct device_node *dn, int type)
 	int i;
 	bool ace_match;
 	struct device_node *cci_portn;
+	int ret = -ENODEV;
 
 	cci_portn = of_parse_phandle(dn, "cci-control-port", 0);
 	for (i = 0; i < nb_cci_ports; i++) {
 		ace_match = ports[i].type == type;
-		if (ace_match && cci_portn == ports[i].dn)
-			return i;
+		if (ace_match && cci_portn == ports[i].dn) {
+			ret = i;
+			break;
+		}
 	}
-	return -ENODEV;
+	of_node_put(cci_portn);
+	return ret;
 }
 
 int cci_ace_get_port(struct device_node *dn)
-- 
2.35.1


             reply	other threads:[~2025-09-02  7:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  7:43 Miaoqian Lin [this message]
2025-09-02  9:44 ` Markus Elfring
2025-09-02 11:11   ` Greg KH

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=20250902074353.2401060-1-linmq006@gmail.com \
    --to=linmq006@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=nico@fluxnic.net \
    --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

all inboxes | Powered by JetHome®