All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: wu000273-OJFnDUYgAso@public.gmane.org, kjlu-OJFnDUYgAso@public.gmane.org
Cc: Liam Girdwood <lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Jaroslav Kysela <perex-/Fr2/VpizcU@public.gmane.org>,
	Takashi Iwai <tiwai-IBi9RG/b67k@public.gmane.org>,
	Thierry Reding
	<thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	YueHaibing <yuehaibing-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
	Ben Dooks <ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>,
	Edward Cragg
	<edward.cragg-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] ASoC: tegra: Fix reference count leaks.
Date: Tue, 16 Jun 2020 20:42:50 +0100	[thread overview]
Message-ID: <9492fa91-067b-f74f-1a52-a2622d8f28d6@nvidia.com> (raw)
In-Reply-To: <20200613204422.24484-1-wu000273-OJFnDUYgAso@public.gmane.org>


On 13/06/2020 21:44, wu000273-OJFnDUYgAso@public.gmane.org wrote:
> From: Qiushi Wu <wu000273-OJFnDUYgAso@public.gmane.org>
> 
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count if pm_runtime_put is not called in
> error handling paths. Call pm_runtime_put if pm_runtime_get_sync fails.
> 
> Signed-off-by: Qiushi Wu <wu000273-OJFnDUYgAso@public.gmane.org>
> ---
>  sound/soc/tegra/tegra30_ahub.c | 4 +++-
>  sound/soc/tegra/tegra30_i2s.c  | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
> index 635eacbd28d4..156e3b9d613c 100644
> --- a/sound/soc/tegra/tegra30_ahub.c
> +++ b/sound/soc/tegra/tegra30_ahub.c
> @@ -643,8 +643,10 @@ static int tegra30_ahub_resume(struct device *dev)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put(dev);
>  		return ret;
> +	}
>  	ret = regcache_sync(ahub->regmap_ahub);
>  	ret |= regcache_sync(ahub->regmap_apbif);
>  	pm_runtime_put(dev);
> diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
> index d59882ec48f1..db5a8587bfa4 100644
> --- a/sound/soc/tegra/tegra30_i2s.c
> +++ b/sound/soc/tegra/tegra30_i2s.c
> @@ -567,8 +567,10 @@ static int tegra30_i2s_resume(struct device *dev)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put(dev);
>  		return ret;
> +	}
>  	ret = regcache_sync(i2s->regmap);
>  	pm_runtime_put(dev);

Thanks.

Reviewed-by: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Cheers
Jon

-- 
nvpublic

WARNING: multiple messages have this Message-ID (diff)
From: Jon Hunter <jonathanh@nvidia.com>
To: <wu000273@umn.edu>, <kjlu@umn.edu>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	YueHaibing <yuehaibing@huawei.com>,
	"Ben Dooks" <ben.dooks@codethink.co.uk>,
	Edward Cragg <edward.cragg@codethink.co.uk>,
	<alsa-devel@alsa-project.org>, <linux-tegra@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ASoC: tegra: Fix reference count leaks.
Date: Tue, 16 Jun 2020 20:42:50 +0100	[thread overview]
Message-ID: <9492fa91-067b-f74f-1a52-a2622d8f28d6@nvidia.com> (raw)
In-Reply-To: <20200613204422.24484-1-wu000273@umn.edu>


On 13/06/2020 21:44, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
> 
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count if pm_runtime_put is not called in
> error handling paths. Call pm_runtime_put if pm_runtime_get_sync fails.
> 
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  sound/soc/tegra/tegra30_ahub.c | 4 +++-
>  sound/soc/tegra/tegra30_i2s.c  | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
> index 635eacbd28d4..156e3b9d613c 100644
> --- a/sound/soc/tegra/tegra30_ahub.c
> +++ b/sound/soc/tegra/tegra30_ahub.c
> @@ -643,8 +643,10 @@ static int tegra30_ahub_resume(struct device *dev)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put(dev);
>  		return ret;
> +	}
>  	ret = regcache_sync(ahub->regmap_ahub);
>  	ret |= regcache_sync(ahub->regmap_apbif);
>  	pm_runtime_put(dev);
> diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
> index d59882ec48f1..db5a8587bfa4 100644
> --- a/sound/soc/tegra/tegra30_i2s.c
> +++ b/sound/soc/tegra/tegra30_i2s.c
> @@ -567,8 +567,10 @@ static int tegra30_i2s_resume(struct device *dev)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put(dev);
>  		return ret;
> +	}
>  	ret = regcache_sync(i2s->regmap);
>  	pm_runtime_put(dev);

Thanks.

Reviewed-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

WARNING: multiple messages have this Message-ID (diff)
From: Jon Hunter <jonathanh@nvidia.com>
To: <wu000273@umn.edu>, <kjlu@umn.edu>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	YueHaibing <yuehaibing@huawei.com>, Takashi Iwai <tiwai@suse.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Edward Cragg <edward.cragg@codethink.co.uk>,
	linux-tegra@vger.kernel.org,
	Ben Dooks <ben.dooks@codethink.co.uk>
Subject: Re: [PATCH] ASoC: tegra: Fix reference count leaks.
Date: Tue, 16 Jun 2020 20:42:50 +0100	[thread overview]
Message-ID: <9492fa91-067b-f74f-1a52-a2622d8f28d6@nvidia.com> (raw)
In-Reply-To: <20200613204422.24484-1-wu000273@umn.edu>


On 13/06/2020 21:44, wu000273@umn.edu wrote:
> From: Qiushi Wu <wu000273@umn.edu>
> 
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count if pm_runtime_put is not called in
> error handling paths. Call pm_runtime_put if pm_runtime_get_sync fails.
> 
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  sound/soc/tegra/tegra30_ahub.c | 4 +++-
>  sound/soc/tegra/tegra30_i2s.c  | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
> index 635eacbd28d4..156e3b9d613c 100644
> --- a/sound/soc/tegra/tegra30_ahub.c
> +++ b/sound/soc/tegra/tegra30_ahub.c
> @@ -643,8 +643,10 @@ static int tegra30_ahub_resume(struct device *dev)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put(dev);
>  		return ret;
> +	}
>  	ret = regcache_sync(ahub->regmap_ahub);
>  	ret |= regcache_sync(ahub->regmap_apbif);
>  	pm_runtime_put(dev);
> diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
> index d59882ec48f1..db5a8587bfa4 100644
> --- a/sound/soc/tegra/tegra30_i2s.c
> +++ b/sound/soc/tegra/tegra30_i2s.c
> @@ -567,8 +567,10 @@ static int tegra30_i2s_resume(struct device *dev)
>  	int ret;
>  
>  	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0)
> +	if (ret < 0) {
> +		pm_runtime_put(dev);
>  		return ret;
> +	}
>  	ret = regcache_sync(i2s->regmap);
>  	pm_runtime_put(dev);

Thanks.

Reviewed-by: Jon Hunter <jonathanh@nvidia.com>

Cheers
Jon

-- 
nvpublic

  parent reply	other threads:[~2020-06-16 19:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13 20:44 [PATCH] ASoC: tegra: Fix reference count leaks wu000273-OJFnDUYgAso
2020-06-13 20:44 ` wu000273
2020-06-13 20:44 ` wu000273
     [not found] ` <20200613204422.24484-1-wu000273-OJFnDUYgAso@public.gmane.org>
2020-06-16 19:42   ` Jon Hunter [this message]
2020-06-16 19:42     ` Jon Hunter
2020-06-16 19:42     ` Jon Hunter
2020-06-17 13:30   ` Mark Brown
2020-06-17 13:30     ` Mark Brown
2020-06-17 13:30     ` Mark Brown

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=9492fa91-067b-f74f-1a52-a2622d8f28d6@nvidia.com \
    --to=jonathanh-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=ben.dooks-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=edward.cragg-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org \
    --cc=kjlu-OJFnDUYgAso@public.gmane.org \
    --cc=lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=perex-/Fr2/VpizcU@public.gmane.org \
    --cc=thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=tiwai-IBi9RG/b67k@public.gmane.org \
    --cc=wu000273-OJFnDUYgAso@public.gmane.org \
    --cc=yuehaibing-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
    /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 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.