Skip to contentSkip to conversation

bus: arm-cci: fix of_node_put() leak in __cci_ace_get_port()

PATCH In review Ashutosh Desai 1 participant 2 messages Apr 17 – May 7 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: arm-cci: fix of_node_put() leak in __cci_ace_get_port()

of_parse_phandle() hands back a node with its refcount bumped. __cci_ace_get_port() uses it only for a pointer comparison against ports[], then both return paths walk away without ever calling of_node_put(), leaking the reference each time.

Add the missing of_node_put() on both return paths.

Fixes ed69bdd8fd9b ("drivers: bus: add ARM CCI support")
---
 drivers/bus/arm-cci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +4 -1
index 7f2baf057128..223b1fe19ba0 100644
@@ -167,9 +167,12 @@ static int __cci_ace_get_port(struct device_node *dn, int type)
 	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)
+		if (ace_match && cci_portn == ports[i].dn) {
+			of_node_put(cci_portn);
 			return i;
+		}
 	}
+	of_node_put(cci_portn);
 	return -ENODEV;
 }
 
Signature · 1 line
2.34.1