* [PATCH] remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init
@ 2022-06-05 8:33 Miaoqian Lin
2022-06-07 1:22 ` Suman Anna
2022-06-14 22:55 ` Mathieu Poirier
0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-06-05 8:33 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Suman Anna, linux-remoteproc,
linux-kernel
Cc: linmq006
Every iteration of for_each_available_child_of_node() decrements
the reference count of the previous node.
When breaking early from a for_each_available_child_of_node() loop,
we need to explicitly call of_node_put() on the child node.
Add missing of_node_put() to avoid refcount leak.
Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
index 4840ad906018..0481926c6975 100644
--- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
@@ -1655,6 +1655,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)
if (!cpdev) {
ret = -ENODEV;
dev_err(dev, "could not get R5 core platform device\n");
+ of_node_put(child);
goto fail;
}
@@ -1663,6 +1664,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)
dev_err(dev, "k3_r5_core_of_init failed, ret = %d\n",
ret);
put_device(&cpdev->dev);
+ of_node_put(child);
goto fail;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init
2022-06-05 8:33 [PATCH] remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init Miaoqian Lin
@ 2022-06-07 1:22 ` Suman Anna
2022-06-14 22:55 ` Mathieu Poirier
1 sibling, 0 replies; 3+ messages in thread
From: Suman Anna @ 2022-06-07 1:22 UTC (permalink / raw)
To: Miaoqian Lin, Bjorn Andersson, Mathieu Poirier, linux-remoteproc,
linux-kernel
Hi Miaoqian,
On 6/5/22 03:33, Miaoqian Lin wrote:
> Every iteration of for_each_available_child_of_node() decrements
> the reference count of the previous node.
> When breaking early from a for_each_available_child_of_node() loop,
> we need to explicitly call of_node_put() on the child node.
> Add missing of_node_put() to avoid refcount leak.
Thanks for catching this.
>
> Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Acked-by: Suman Anna <s-anna@ti.com>
regards
Suman
> ---
> drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index 4840ad906018..0481926c6975 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1655,6 +1655,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)
> if (!cpdev) {
> ret = -ENODEV;
> dev_err(dev, "could not get R5 core platform device\n");
> + of_node_put(child);
> goto fail;
> }
>
> @@ -1663,6 +1664,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)
> dev_err(dev, "k3_r5_core_of_init failed, ret = %d\n",
> ret);
> put_device(&cpdev->dev);
> + of_node_put(child);
> goto fail;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init
2022-06-05 8:33 [PATCH] remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init Miaoqian Lin
2022-06-07 1:22 ` Suman Anna
@ 2022-06-14 22:55 ` Mathieu Poirier
1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2022-06-14 22:55 UTC (permalink / raw)
To: Miaoqian Lin; +Cc: Bjorn Andersson, Suman Anna, linux-remoteproc, linux-kernel
On Sun, Jun 05, 2022 at 12:33:34PM +0400, Miaoqian Lin wrote:
> Every iteration of for_each_available_child_of_node() decrements
> the reference count of the previous node.
> When breaking early from a for_each_available_child_of_node() loop,
> we need to explicitly call of_node_put() on the child node.
> Add missing of_node_put() to avoid refcount leak.
>
> Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
> drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 ++
> 1 file changed, 2 insertions(+)
I have applied this patch.
Thanks,
Mathieu
>
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index 4840ad906018..0481926c6975 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1655,6 +1655,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)
> if (!cpdev) {
> ret = -ENODEV;
> dev_err(dev, "could not get R5 core platform device\n");
> + of_node_put(child);
> goto fail;
> }
>
> @@ -1663,6 +1664,7 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev)
> dev_err(dev, "k3_r5_core_of_init failed, ret = %d\n",
> ret);
> put_device(&cpdev->dev);
> + of_node_put(child);
> goto fail;
> }
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-14 22:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-05 8:33 [PATCH] remoteproc: k3-r5: Fix refcount leak in k3_r5_cluster_of_init Miaoqian Lin
2022-06-07 1:22 ` Suman Anna
2022-06-14 22:55 ` Mathieu Poirier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox