Skip to contentSkip to conversation

remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init

PATCH Applied Miaoqian Lin 2 participants 2 messages May 12, 2022 – Jun 22, 2022

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

PATCH 1/1 remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not needed anymore. This function has two paths missing of_node_put().

Fixes 6e962bfe56b9 ("remoteproc: imx_rproc: add missing of_node_put")
Fixes a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver")
---
 drivers/remoteproc/imx_rproc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/remoteproc/imx_rproc.c +4 -3
index 7a096f1891e6..6363ed40854a 100644
@@ -559,16 +559,17 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
 		node = of_parse_phandle(np, "memory-region", a);
 		/* Not map vdevbuffer, vdevring region */
-		if (!strncmp(node->name, "vdev", strlen("vdev")))
+		if (!strncmp(node->name, "vdev", strlen("vdev"))) {
+			of_node_put(node);
 			continue;
+		}
 		err = of_address_to_resource(node, 0, &res);
+		of_node_put(node);
 		if (err) {
 			dev_err(dev, "unable to resolve memory region\n");
 			return err;
 		}
 
-		of_node_put(node);
-
 		if (b >= IMX_RPROC_MEM_MAX)
 			break;
 
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 16 lines · Miaoqian Lin

of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not needed anymore. This function has two paths missing of_node_put().

Fixes 6e962bfe56b9 ("remoteproc: imx_rproc: add missing of_node_put")
Fixes a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver")
---
 drivers/remoteproc/imx_rproc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/remoteproc/imx_rproc.c +0 -0
index 7a096f1891e6..6363ed40854a 100644

drivers/remoteproc/imx_rproc.c static int imx_rproc_addr_init(struct imx_rproc *priv, · line 567

Quoted 10 lines
drivers/remoteproc/imx_rproc.c +4 -1
@@ -559,16 +559,17 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
 		node = of_parse_phandle(np, "memory-region", a);
 		/* Not map vdevbuffer, vdevring region */
-		if (!strncmp(node->name, "vdev", strlen("vdev")))
+		if (!strncmp(node->name, "vdev", strlen("vdev"))) {
+			of_node_put(node);
 			continue;
+		}
 		err = of_address_to_resource(node, 0, &res);
+		of_node_put(node);

Applied.

Thanks,
Mathieu

Quoted 13 lines
drivers/remoteproc/imx_rproc.c +0 -2
 		if (err) {
 			dev_err(dev, "unable to resolve memory region\n");
 			return err;
 		}
 
-		of_node_put(node);
-
 		if (b >= IMX_RPROC_MEM_MAX)
 			break;
 
Signature · 1 line
2.25.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel