bus: arm-cci: Fix a reference leak in __cci_ace_get_port()
PATCH 1/1 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 <[email protected]>
--- drivers/bus/arm-cci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/bus/arm-cci.c +3 -3
@@ -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,
Signature · 1 line
Felix Gu <[email protected]>