[PATCH] drivers: bus: fix device node reference leak in __cci_ace_get_port

Miaoqian Lin posted 1 patch 1 month ago
drivers/bus/arm-cci.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH] drivers: bus: fix device node reference leak in __cci_ace_get_port
Posted by Miaoqian Lin 1 month ago
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
Re: [PATCH] drivers: bus: fix device node reference leak in __cci_ace_get_port
Posted by Markus Elfring 1 month ago
> Add missing of_node_put() call to release
> the device node reference obtained via of_parse_phandle().

1. You may occasionally put more than 58 characters into text lines
   of such a change description.
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n638

2. Would you like to increase the application of scope-based resource management?
   https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/of.h#L138

3. How do you think about to append parentheses to the function name
   in the summary phrase?


Regards,
Markus
Re: [PATCH] drivers: bus: fix device node reference leak in __cci_ace_get_port
Posted by Greg KH 1 month ago
On Tue, Sep 02, 2025 at 11:44:10AM +0200, Markus Elfring wrote:
> > Add missing of_node_put() call to release
> > the device node reference obtained via of_parse_phandle().
> 
> 1. You may occasionally put more than 58 characters into text lines
>    of such a change description.
>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n638
> 
> 2. Would you like to increase the application of scope-based resource management?
>    https://elixir.bootlin.com/linux/v6.17-rc4/source/include/linux/of.h#L138
> 
> 3. How do you think about to append parentheses to the function name
>    in the summary phrase?
> 


Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless
review comment to a patch submission on a Linux kernel developer mailing
list.  I strongly suggest that you not do this anymore.  Please do not
bother developers who are actively working to produce patches and
features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to
follow it at all.  The person/bot/AI that sent it is being ignored by
almost all Linux kernel maintainers for having a persistent pattern of
behavior of producing distracting and pointless commentary, and
inability to adapt to feedback.  Please feel free to also ignore emails
from them.

thanks,

greg k-h's patch email bot