All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed
@ 2022-07-21 20:40 Uwe Kleine-König
  2022-07-22  1:36 ` Baolin Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2022-07-21 20:40 UTC (permalink / raw)
  To: Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang; +Cc: dmaengine, kernel

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(-)

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


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

* Re: [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed
  2022-07-21 20:40 [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed Uwe Kleine-König
@ 2022-07-22  1:36 ` Baolin Wang
  2022-07-22  8:21 ` Uwe Kleine-König
  2022-07-26 12:51 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Baolin Wang @ 2022-07-22  1:36 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Vinod Koul, Orson Zhai, Chunyan Zhang, dmaengine, kernel

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
>


-- 
Baolin Wang

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

* Re: [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed
  2022-07-21 20:40 [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed Uwe Kleine-König
  2022-07-22  1:36 ` Baolin Wang
@ 2022-07-22  8:21 ` Uwe Kleine-König
  2022-07-26 12:51 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2022-07-22  8:21 UTC (permalink / raw)
  To: Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang; +Cc: dmaengine, kernel

[-- Attachment #1: Type: text/plain, Size: 952 bytes --]

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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed
  2022-07-21 20:40 [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed Uwe Kleine-König
  2022-07-22  1:36 ` Baolin Wang
  2022-07-22  8:21 ` Uwe Kleine-König
@ 2022-07-26 12:51 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2022-07-26 12:51 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Orson Zhai, Baolin Wang, Chunyan Zhang, dmaengine, kernel

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

-- 
~Vinod

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

end of thread, other threads:[~2022-07-26 12:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 20:40 [PATCH] dmaengine: sprd: Cleanup in .remove() after pm_runtime_get_sync() failed Uwe Kleine-König
2022-07-22  1:36 ` Baolin Wang
2022-07-22  8:21 ` Uwe Kleine-König
2022-07-26 12:51 ` Vinod Koul

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.