Thread (3 messages) 3 messages, 2 authors, 2021-05-17

Re: [PATCH] media: hantro: Fix PM reference leak in device_run()

From: Johan Hovold <johan@kernel.org>
Date: 2021-05-17 08:22:09
Also in: linux-media, linux-rockchip, lkml

On Mon, May 17, 2021 at 04:15:16PM +0800, Yu Kuai wrote:
quoted hunk ↗ jump to hunk
pm_runtime_get_sync will increment pm usage counter even it failed.
Forgetting to putting operation will result in reference leak here.
Fix it by replacing it with pm_runtime_resume_and_get to keep usage
counter balanced.

Reported-by: Hulk Robot <redacted>
Signed-off-by: Yu Kuai <redacted>
---
 drivers/staging/media/hantro/hantro_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index eea2009fa17b..7a6d3ef22096 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -160,7 +160,7 @@ static void device_run(void *priv)
 	src = hantro_get_src_buf(ctx);
 	dst = hantro_get_dst_buf(ctx);
 
-	ret = pm_runtime_get_sync(ctx->dev->dev);
+	ret = pm_runtime_resume_and_get(ctx->dev->dev);
 	if (ret < 0) {
 		pm_runtime_put_noidle(ctx->dev->dev);
This is clearly broken as there is no PM usage count leak here.

Please try to understand the code you're changing before submitting any
more patches based on "robot" feedback.
 		goto err_cancel_job;
Johan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help