All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init
@ 2022-05-12  4:55 ` Miaoqian Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-05-12  4:55 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team, Peng Fan,
	Oleksij Rempel, linux-remoteproc, linux-arm-kernel, linux-kernel
  Cc: linmq006

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")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/remoteproc/imx_rproc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 7a096f1891e6..6363ed40854a 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init
@ 2022-05-12  4:55 ` Miaoqian Lin
  0 siblings, 0 replies; 4+ messages in thread
From: Miaoqian Lin @ 2022-05-12  4:55 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team, Peng Fan,
	Oleksij Rempel, linux-remoteproc, linux-arm-kernel, linux-kernel
  Cc: linmq006

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")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/remoteproc/imx_rproc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 7a096f1891e6..6363ed40854a 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -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;
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init
  2022-05-12  4:55 ` Miaoqian Lin
@ 2022-06-22 16:48   ` Mathieu Poirier
  -1 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2022-06-22 16:48 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Bjorn Andersson, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team, Peng Fan,
	Oleksij Rempel, linux-remoteproc, linux-arm-kernel, linux-kernel

On Thu, May 12, 2022 at 08:55:58AM +0400, Miaoqian Lin wrote:
> 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")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 7a096f1891e6..6363ed40854a 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -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

>  		if (err) {
>  			dev_err(dev, "unable to resolve memory region\n");
>  			return err;
>  		}
>  
> -		of_node_put(node);
> -
>  		if (b >= IMX_RPROC_MEM_MAX)
>  			break;
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init
@ 2022-06-22 16:48   ` Mathieu Poirier
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Poirier @ 2022-06-22 16:48 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: Bjorn Andersson, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, NXP Linux Team, Peng Fan,
	Oleksij Rempel, linux-remoteproc, linux-arm-kernel, linux-kernel

On Thu, May 12, 2022 at 08:55:58AM +0400, Miaoqian Lin wrote:
> 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")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 7a096f1891e6..6363ed40854a 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -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

>  		if (err) {
>  			dev_err(dev, "unable to resolve memory region\n");
>  			return err;
>  		}
>  
> -		of_node_put(node);
> -
>  		if (b >= IMX_RPROC_MEM_MAX)
>  			break;
>  
> -- 
> 2.25.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-22 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12  4:55 [PATCH] remoteproc: imx_rproc: Fix refcount leak in imx_rproc_addr_init Miaoqian Lin
2022-05-12  4:55 ` Miaoqian Lin
2022-06-22 16:48 ` Mathieu Poirier
2022-06-22 16:48   ` Mathieu Poirier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.