Skip to contentSkip to conversation

soc: fsl: qe: Fix refcount leak in par_io_of_config

PATCH New Miaoqian Lin 1 participant 1 message Apr 3, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: fsl: qe: Fix refcount leak in par_io_of_config

The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. This function only calls of_node_put() in the regular path. And it will cause refcount leak in error path.

Fixes 986585385131 ("[POWERPC] Add QUICC Engine (QE) infrastructure")
---
 drivers/soc/fsl/qe/qe_io.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/fsl/qe/qe_io.c +6 -2
index a5e2d0e5ab51..9f5f746bea88 100644
@@ -159,12 +159,12 @@ int par_io_of_config(struct device_node *np)
 	pio_map = of_get_property(pio, "pio-map", &pio_map_len);
 	if (pio_map == NULL) {
 		printk(KERN_ERR "pio-map is not set!\n");
-		return -1;
+		goto err_node_put;
 	}
 	pio_map_len /= sizeof(unsigned int);
 	if ((pio_map_len % 6) != 0) {
 		printk(KERN_ERR "pio-map format wrong!\n");
-		return -1;
+		goto err_node_put;
 	}
 
 	while (pio_map_len > 0) {
@@ -182,5 +182,9 @@ int par_io_of_config(struct device_node *np)
 	}
 	of_node_put(pio);
 	return 0;
+
+err_node_put:
+	of_node_put(pio);
+	return -1;
 }
 EXPORT_SYMBOL(par_io_of_config);
Signature · 1 line
2.17.1