diff mbox series

dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed

Message ID 20220721204054.323602-1-u.kleine-koenig@pengutronix.de (mailing list archive)
State Accepted
Commit 1e42f82cbec7b2cc4873751e7791e6611901c5fc
Headers show
Series dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed | expand

Commit Message

Uwe Kleine-König July 21, 2022, 8:40 p.m. UTC
It's not allowed to quit remove early without cleaning up completely.
Otherwise this results in resource leaks that probably yield graver
problems later. Here for example some tasklets might survive the lifetime
of the sprd-dma device and access sdev which is freed after .remove()
returns.

As none of the device freeing requires an active device, just ignore the
return value of pm_runtime_get_sync().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/dma/sprd-dma.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)


base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56

Comments

Baolin Wang July 22, 2022, 1:36 a.m. UTC | #1
On Fri, Jul 22, 2022 at 4:41 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> It's not allowed to quit remove early without cleaning up completely.
> Otherwise this results in resource leaks that probably yield graver
> problems later. Here for example some tasklets might survive the lifetime
> of the sprd-dma device and access sdev which is freed after .remove()
> returns.
>
> As none of the device freeing requires an active device, just ignore the
> return value of pm_runtime_get_sync().
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

It makes sense to me. Thanks.
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>

> ---
>  drivers/dma/sprd-dma.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 2138b80435ab..474d3ba8ec9f 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1237,11 +1237,8 @@ static int sprd_dma_remove(struct platform_device *pdev)
>  {
>         struct sprd_dma_dev *sdev = platform_get_drvdata(pdev);
>         struct sprd_dma_chn *c, *cn;
> -       int ret;
>
> -       ret = pm_runtime_get_sync(&pdev->dev);
> -       if (ret < 0)
> -               return ret;
> +       pm_runtime_get_sync(&pdev->dev);
>
>         /* explicitly free the irq */
>         if (sdev->irq > 0)
>
> base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
> --
> 2.36.1
>
Uwe Kleine-König July 22, 2022, 8:21 a.m. UTC | #2
On Thu, Jul 21, 2022 at 10:40:54PM +0200, Uwe Kleine-König wrote:
> It's not allowed to quit remove early without cleaning up completely.
> Otherwise this results in resource leaks that probably yield graver
> problems later. Here for example some tasklets might survive the lifetime
> of the sprd-dma device and access sdev which is freed after .remove()
> returns.
> 
> As none of the device freeing requires an active device, just ignore the
> return value of pm_runtime_get_sync().
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

If you want a fixes line, that would be:

Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")

but I'm not sure this is critical enough to be backported to stable. So
apply at will.

Best regards
Uwe
Vinod Koul July 26, 2022, 12:51 p.m. UTC | #3
On 21-07-22, 22:40, Uwe Kleine-König wrote:
> It's not allowed to quit remove early without cleaning up completely.
> Otherwise this results in resource leaks that probably yield graver
> problems later. Here for example some tasklets might survive the lifetime
> of the sprd-dma device and access sdev which is freed after .remove()
> returns.
> 
> As none of the device freeing requires an active device, just ignore the
> return value of pm_runtime_get_sync().

Applied, thanks

> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/dma/sprd-dma.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 2138b80435ab..474d3ba8ec9f 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1237,11 +1237,8 @@ static int sprd_dma_remove(struct platform_device *pdev)
>  {
>  	struct sprd_dma_dev *sdev = platform_get_drvdata(pdev);
>  	struct sprd_dma_chn *c, *cn;
> -	int ret;
>  
> -	ret = pm_runtime_get_sync(&pdev->dev);
> -	if (ret < 0)
> -		return ret;
> +	pm_runtime_get_sync(&pdev->dev);
>  
>  	/* explicitly free the irq */
>  	if (sdev->irq > 0)
> 
> base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56
> -- 
> 2.36.1
diff mbox series

Patch

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 2138b80435ab..474d3ba8ec9f 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -1237,11 +1237,8 @@  static int sprd_dma_remove(struct platform_device *pdev)
 {
 	struct sprd_dma_dev *sdev = platform_get_drvdata(pdev);
 	struct sprd_dma_chn *c, *cn;
-	int ret;
 
-	ret = pm_runtime_get_sync(&pdev->dev);
-	if (ret < 0)
-		return ret;
+	pm_runtime_get_sync(&pdev->dev);
 
 	/* explicitly free the irq */
 	if (sdev->irq > 0)