[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20260122-b4-arm-cci-v1-1-ad928c14ea24@gmail.com>
Date: Thu, 22 Jan 2026 02:39:17 +0800
From: Felix Gu <ustc.gu@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Felix Gu <ustc.gu@...il.com>
Subject: [PATCH] bus: arm-cci: Fix a reference leak in __cci_ace_get_port()
In __cci_ace_get_port(), cci_portn is obtained via of_parse_phandle(), which
increments the refcount.
Use __free(device_node) scope-based cleanup to automatically release
the reference when the variable goes out of scope.
Signed-off-by: Felix Gu <ustc.gu@...il.com>
---
drivers/bus/arm-cci.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index b8184a903583..766cccb840c1 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -15,6 +15,7 @@
*/
#include <linux/arm-cci.h>
+#include <linux/cleanup.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
@@ -162,9 +163,8 @@ static int __cci_ace_get_port(struct device_node *dn, int type)
{
int i;
bool ace_match;
- struct device_node *cci_portn;
-
- cci_portn = of_parse_phandle(dn, "cci-control-port", 0);
+ struct device_node *cci_portn __free(device_node) =
+ 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)
---
base-commit: 053966c344dbd346e71305f530e91ea77916189f
change-id: 20260122-b4-arm-cci-625234044b70
Best regards,
--
Felix Gu <ustc.gu@...il.com>
Powered by blists - more mailing lists