diff mbox series

remoteproc: imx_rproc: Fix a resource leak in the remove function

Message ID d28ca94a4031bd7297d47c2164e18885a5a6ec19.1634366546.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Headers show
Series remoteproc: imx_rproc: Fix a resource leak in the remove function | expand

Commit Message

Christophe JAILLET Oct. 16, 2021, 6:44 a.m. UTC
'priv->workqueue' is destroyed in the error handling path of the probe but
not in the remove function.

Add the missing call to release some resources.

Fixes: 2df7062002d0 ("remoteproc: imx_proc: enable virtio/mailbox")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative. I'm not sure if the added function call is at
the right place in the remove function.
Review with care.
---
 drivers/remoteproc/imx_rproc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Mathieu Poirier Oct. 21, 2021, 5:41 p.m. UTC | #1
On Sat, Oct 16, 2021 at 08:44:28AM +0200, Christophe JAILLET wrote:
> 'priv->workqueue' is destroyed in the error handling path of the probe but
> not in the remove function.
> 
> Add the missing call to release some resources.
> 
> Fixes: 2df7062002d0 ("remoteproc: imx_proc: enable virtio/mailbox")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is speculative. I'm not sure if the added function call is at
> the right place in the remove function.
> Review with care.
> ---
>  drivers/remoteproc/imx_rproc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index ff8170dbbc3c..0a45bc0d3f73 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -804,6 +804,7 @@ static int imx_rproc_remove(struct platform_device *pdev)
>  	clk_disable_unprepare(priv->clk);
>  	rproc_del(rproc);
>  	imx_rproc_free_mbox(rproc);
> +	destroy_workqueue(priv->workqueue);

This seems to be the right thing to do. Peng - please review and test on your
side.

Thanks,
Mathieu

>  	rproc_free(rproc);
>  
>  	return 0;
> -- 
> 2.30.2
>
Peng Fan Nov. 10, 2021, 8:45 a.m. UTC | #2
> Subject: [PATCH] remoteproc: imx_rproc: Fix a resource leak in the remove
> function
> 
> 'priv->workqueue' is destroyed in the error handling path of the probe but not
> in the remove function.
> 
> Add the missing call to release some resources.
> 
> Fixes: 2df7062002d0 ("remoteproc: imx_proc: enable virtio/mailbox")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>


Tested-by: Peng Fan <peng.fan@nxp.com>

> ---
> This patch is speculative. I'm not sure if the added function call is at the right
> place in the remove function.
> Review with care.
> ---
>  drivers/remoteproc/imx_rproc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c
> b/drivers/remoteproc/imx_rproc.c index ff8170dbbc3c..0a45bc0d3f73
> 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -804,6 +804,7 @@ static int imx_rproc_remove(struct platform_device
> *pdev)
>  	clk_disable_unprepare(priv->clk);
>  	rproc_del(rproc);
>  	imx_rproc_free_mbox(rproc);
> +	destroy_workqueue(priv->workqueue);
>  	rproc_free(rproc);
> 
>  	return 0;
> --
> 2.30.2
Peng Fan Nov. 10, 2021, 8:53 a.m. UTC | #3
> Subject: Re: [PATCH] remoteproc: imx_rproc: Fix a resource leak in the
> remove function
> 
> On Sat, Oct 16, 2021 at 08:44:28AM +0200, Christophe JAILLET wrote:
> > 'priv->workqueue' is destroyed in the error handling path of the probe
> > but not in the remove function.
> >
> > Add the missing call to release some resources.
> >
> > Fixes: 2df7062002d0 ("remoteproc: imx_proc: enable virtio/mailbox")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > ---
> > This patch is speculative. I'm not sure if the added function call is
> > at the right place in the remove function.
> > Review with care.
> > ---
> >  drivers/remoteproc/imx_rproc.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/remoteproc/imx_rproc.c
> > b/drivers/remoteproc/imx_rproc.c index ff8170dbbc3c..0a45bc0d3f73
> > 100644
> > --- a/drivers/remoteproc/imx_rproc.c
> > +++ b/drivers/remoteproc/imx_rproc.c
> > @@ -804,6 +804,7 @@ static int imx_rproc_remove(struct platform_device
> *pdev)
> >  	clk_disable_unprepare(priv->clk);
> >  	rproc_del(rproc);
> >  	imx_rproc_free_mbox(rproc);
> > +	destroy_workqueue(priv->workqueue);
> 
> This seems to be the right thing to do. Peng - please review and test on your
> side.

Sorry for late reply, I built the driver as a module with this patch. And no issue found.

THnaks,
Peng.

> 
> Thanks,
> Mathieu
> 
> >  	rproc_free(rproc);
> >
> >  	return 0;
> > --
> > 2.30.2
> >
Peng Fan Nov. 10, 2021, 8:54 a.m. UTC | #4
> Subject: [PATCH] remoteproc: imx_rproc: Fix a resource leak in the remove
> function
> 
> 'priv->workqueue' is destroyed in the error handling path of the probe but not
> in the remove function.
> 
> Add the missing call to release some resources.
> 
> Fixes: 2df7062002d0 ("remoteproc: imx_proc: enable virtio/mailbox")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-and-Tested-by: Peng Fan <peng.fan@nxp.com>

> ---
> This patch is speculative. I'm not sure if the added function call is at the right
> place in the remove function.
> Review with care.
> ---
>  drivers/remoteproc/imx_rproc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c
> b/drivers/remoteproc/imx_rproc.c index ff8170dbbc3c..0a45bc0d3f73
> 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -804,6 +804,7 @@ static int imx_rproc_remove(struct platform_device
> *pdev)
>  	clk_disable_unprepare(priv->clk);
>  	rproc_del(rproc);
>  	imx_rproc_free_mbox(rproc);
> +	destroy_workqueue(priv->workqueue);
>  	rproc_free(rproc);
> 
>  	return 0;
> --
> 2.30.2
Mathieu Poirier Nov. 11, 2021, 6:20 p.m. UTC | #5
On Wed, 10 Nov 2021 at 01:54, Peng Fan <peng.fan@nxp.com> wrote:
>
> > Subject: [PATCH] remoteproc: imx_rproc: Fix a resource leak in the remove
> > function
> >
> > 'priv->workqueue' is destroyed in the error handling path of the probe but not
> > in the remove function.
> >
> > Add the missing call to release some resources.
> >
> > Fixes: 2df7062002d0 ("remoteproc: imx_proc: enable virtio/mailbox")
> > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> Reviewed-and-Tested-by: Peng Fan <peng.fan@nxp.com>
>

Thank you for that - I will pick up this patch when -rc1 or -rc2 gets released.

Thanks,
Mathieu

> > ---
> > This patch is speculative. I'm not sure if the added function call is at the right
> > place in the remove function.
> > Review with care.
> > ---
> >  drivers/remoteproc/imx_rproc.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/remoteproc/imx_rproc.c
> > b/drivers/remoteproc/imx_rproc.c index ff8170dbbc3c..0a45bc0d3f73
> > 100644
> > --- a/drivers/remoteproc/imx_rproc.c
> > +++ b/drivers/remoteproc/imx_rproc.c
> > @@ -804,6 +804,7 @@ static int imx_rproc_remove(struct platform_device
> > *pdev)
> >       clk_disable_unprepare(priv->clk);
> >       rproc_del(rproc);
> >       imx_rproc_free_mbox(rproc);
> > +     destroy_workqueue(priv->workqueue);
> >       rproc_free(rproc);
> >
> >       return 0;
> > --
> > 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index ff8170dbbc3c..0a45bc0d3f73 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -804,6 +804,7 @@  static int imx_rproc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(priv->clk);
 	rproc_del(rproc);
 	imx_rproc_free_mbox(rproc);
+	destroy_workqueue(priv->workqueue);
 	rproc_free(rproc);
 
 	return 0;