All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: hantro: Fix PM reference leak in device_run()
@ 2021-05-17  8:15 ` Yu Kuai
  0 siblings, 0 replies; 6+ messages in thread
From: Yu Kuai @ 2021-05-17  8:15 UTC (permalink / raw)
  To: ezequiel, p.zabel, mchehab, gregkh
  Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
	yukuai3, yi.zhang

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 <hulkci@huawei.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 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);
 		goto err_cancel_job;
-- 
2.25.4


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

* [PATCH] media: hantro: Fix PM reference leak in device_run()
@ 2021-05-17  8:15 ` Yu Kuai
  0 siblings, 0 replies; 6+ messages in thread
From: Yu Kuai @ 2021-05-17  8:15 UTC (permalink / raw)
  To: ezequiel, p.zabel, mchehab, gregkh
  Cc: linux-media, linux-rockchip, linux-staging, linux-kernel,
	yukuai3, yi.zhang

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 <hulkci@huawei.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 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);
 		goto err_cancel_job;
-- 
2.25.4


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] media: hantro: Fix PM reference leak in device_run()
  2021-05-17  8:15 ` Yu Kuai
@ 2021-05-17  8:22   ` Johan Hovold
  -1 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2021-05-17  8:22 UTC (permalink / raw)
  To: Yu Kuai
  Cc: ezequiel, p.zabel, mchehab, gregkh, linux-media, linux-rockchip,
	linux-staging, linux-kernel, yi.zhang

On Mon, May 17, 2021 at 04:15:16PM +0800, Yu Kuai wrote:
> 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 <hulkci@huawei.com>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>  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

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

* Re: [PATCH] media: hantro: Fix PM reference leak in device_run()
@ 2021-05-17  8:22   ` Johan Hovold
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2021-05-17  8:22 UTC (permalink / raw)
  To: Yu Kuai
  Cc: ezequiel, p.zabel, mchehab, gregkh, linux-media, linux-rockchip,
	linux-staging, linux-kernel, yi.zhang

On Mon, May 17, 2021 at 04:15:16PM +0800, Yu Kuai wrote:
> 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 <hulkci@huawei.com>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>  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

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] media: hantro: Fix PM reference leak in device_run()
  2021-05-17  8:22   ` Johan Hovold
@ 2021-05-17 12:35     ` yukuai (C)
  -1 siblings, 0 replies; 6+ messages in thread
From: yukuai (C) @ 2021-05-17 12:35 UTC (permalink / raw)
  To: Johan Hovold
  Cc: ezequiel, p.zabel, mchehab, gregkh, linux-media, linux-rockchip,
	linux-staging, linux-kernel, yi.zhang

On 2021/05/17 16:22, Johan Hovold wrote:
> On Mon, May 17, 2021 at 04:15:16PM +0800, Yu Kuai wrote:
>> 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 <hulkci@huawei.com>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   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.

Hi,

Sorry about the mistake, and thank you very much for your explanation

Yu Kuai
> 
>>   		goto err_cancel_job;
> 
> Johan
> .
> 

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

* Re: [PATCH] media: hantro: Fix PM reference leak in device_run()
@ 2021-05-17 12:35     ` yukuai (C)
  0 siblings, 0 replies; 6+ messages in thread
From: yukuai (C) @ 2021-05-17 12:35 UTC (permalink / raw)
  To: Johan Hovold
  Cc: ezequiel, p.zabel, mchehab, gregkh, linux-media, linux-rockchip,
	linux-staging, linux-kernel, yi.zhang

On 2021/05/17 16:22, Johan Hovold wrote:
> On Mon, May 17, 2021 at 04:15:16PM +0800, Yu Kuai wrote:
>> 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 <hulkci@huawei.com>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   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.

Hi,

Sorry about the mistake, and thank you very much for your explanation

Yu Kuai
> 
>>   		goto err_cancel_job;
> 
> Johan
> .
> 

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2021-05-17 12:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  8:15 [PATCH] media: hantro: Fix PM reference leak in device_run() Yu Kuai
2021-05-17  8:15 ` Yu Kuai
2021-05-17  8:22 ` Johan Hovold
2021-05-17  8:22   ` Johan Hovold
2021-05-17 12:35   ` yukuai (C)
2021-05-17 12:35     ` yukuai (C)

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.