bus: arm-cci: fix of_node_put() leak in __cci_ace_get_port()
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")
Signed-off-by Ashutosh Desai <[email protected]>
--- drivers/bus/arm-cci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/bus/arm-cci.c +4 -1
@@ -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
Hi Lorenzo, Nicolas,
Just a gentle ping on this patch from a few weeks ago - no rush at all, I know you're busy.
https://lore.kernel.org/linux-kernel/[email protected]/
Happy to revise anything if needed. Thanks for your time!
Ashutosh