[PATCH] bus: arm-cci: Fix a reference leak in __cci_ace_get_port()

Felix Gu posted 1 patch 2 weeks, 4 days ago
drivers/bus/arm-cci.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] bus: arm-cci: Fix a reference leak in __cci_ace_get_port()
Posted by Felix Gu 2 weeks, 4 days ago
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@gmail.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@gmail.com>