public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Yu Kuai <yukuai3@huawei.com>
Cc: ezequiel@collabora.com, p.zabel@pengutronix.de,
	mchehab@kernel.org, gregkh@linuxfoundation.org,
	linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
	yi.zhang@huawei.com
Subject: Re: [PATCH] media: hantro: Fix PM reference leak in device_run()
Date: Mon, 17 May 2021 10:22:04 +0200	[thread overview]
Message-ID: <YKInrIMZYGI1VKdl@hovoldconsulting.com> (raw)
In-Reply-To: <20210517081516.1562794-1-yukuai3@huawei.com>

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

  reply	other threads:[~2021-05-17  8:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  8:15 [PATCH] media: hantro: Fix PM reference leak in device_run() Yu Kuai
2021-05-17  8:22 ` Johan Hovold [this message]
2021-05-17 12:35   ` yukuai (C)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKInrIMZYGI1VKdl@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=ezequiel@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox