All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix reference counter leak in error banch
@ 2020-11-09 13:13 Zhang Qilong
  2020-11-09 13:13 ` [PATCH 1/2] staging: greybus: codecs: Fix reference counter leak in error handling Zhang Qilong
  2020-11-09 13:13 ` [PATCH 2/2] greybus: audio: apbridgea: " Zhang Qilong
  0 siblings, 2 replies; 4+ messages in thread
From: Zhang Qilong @ 2020-11-09 13:13 UTC (permalink / raw)
  To: vaibhav.sr, mgreer, johan, elder, gregkh; +Cc: devel, greybus-dev

There are two reference counter leaks in greybus moduler refer to
gb_pm_runtime_get_sync, and we fixed it.

Zhang Qilong (2):
  staging: greybus: codecs: Fix reference counter leak in error handling
  greybus: audio: apbridgea: Fix reference counter leak in error
    handling

 drivers/staging/greybus/audio_apbridgea.c | 6 +++++-
 drivers/staging/greybus/audio_codec.c     | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.25.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 1/2] staging: greybus: codecs: Fix reference counter leak in error handling
  2020-11-09 13:13 [PATCH 0/2] Fix reference counter leak in error banch Zhang Qilong
@ 2020-11-09 13:13 ` Zhang Qilong
  2020-11-09 13:13 ` [PATCH 2/2] greybus: audio: apbridgea: " Zhang Qilong
  1 sibling, 0 replies; 4+ messages in thread
From: Zhang Qilong @ 2020-11-09 13:13 UTC (permalink / raw)
  To: vaibhav.sr, mgreer, johan, elder, gregkh; +Cc: devel, greybus-dev

gb_pm_runtime_get_sync has increased the usage counter of the device here.
Forgetting to call gb_pm_runtime_put_noidle will result in usage counter
leak in the error branch of (gbcodec_hw_params and gbcodec_prepare). We
fixed it by adding it.

Fixes: c388ae7696992 ("greybus: audio: Update pm runtime support in dai_ops callback")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/staging/greybus/audio_codec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
index 17a39ed63769..b589cf6b1d03 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -471,6 +471,7 @@ static int gbcodec_hw_params(struct snd_pcm_substream *substream,
 	if (ret) {
 		dev_err_ratelimited(dai->dev, "%d: Error during set_config\n",
 				    ret);
+		gb_pm_runtime_put_noidle(bundle);
 		mutex_unlock(&codec->lock);
 		return ret;
 	}
@@ -545,6 +546,7 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream,
 		break;
 	}
 	if (ret) {
+		gb_pm_runtime_put_noidle(bundle);
 		mutex_unlock(&codec->lock);
 		dev_err_ratelimited(dai->dev, "set_data_size failed:%d\n", ret);
 		return ret;
-- 
2.25.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 2/2] greybus: audio: apbridgea: Fix reference counter leak in error handling
  2020-11-09 13:13 [PATCH 0/2] Fix reference counter leak in error banch Zhang Qilong
  2020-11-09 13:13 ` [PATCH 1/2] staging: greybus: codecs: Fix reference counter leak in error handling Zhang Qilong
@ 2020-11-09 13:13 ` Zhang Qilong
  2020-11-13 23:27   ` [PATCH 2/2] staging: " Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Zhang Qilong @ 2020-11-09 13:13 UTC (permalink / raw)
  To: vaibhav.sr, mgreer, johan, elder, gregkh; +Cc: devel, greybus-dev

When gb_audio_apbridgea_register_cport failed, maybe:

  1) gb_pm_runtime_get_sync failed, usage counter remained unchanged;

  2) gb_hd_output failed, usage counter remained increased;

In error state, there are two different states in usage cpounter. So,
if gb_hd_output failed, we should call gb_pm_runtime_put_autosuspend
ot decrease usage counter for balabce preventing reference leak. And
we fixed it by add gb_pm_runtime_put_autosuspend when gb_hd_output
failed.

Fixes: 6ba7fad430d63 ("Add runtime pm support to audio protocol device class driver.")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/staging/greybus/audio_apbridgea.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/audio_apbridgea.c b/drivers/staging/greybus/audio_apbridgea.c
index 26117e390deb..50545fd9756c 100644
--- a/drivers/staging/greybus/audio_apbridgea.c
+++ b/drivers/staging/greybus/audio_apbridgea.c
@@ -42,8 +42,12 @@ int gb_audio_apbridgea_register_cport(struct gb_connection *connection,
 	if (ret)
 		return ret;
 
-	return gb_hd_output(connection->hd, &req, sizeof(req),
+	ret = gb_hd_output(connection->hd, &req, sizeof(req),
 			    GB_APB_REQUEST_AUDIO_CONTROL, true);
+	if (ret)
+		gb_pm_runtime_put_autosuspend(connection->bundle);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(gb_audio_apbridgea_register_cport);
 
-- 
2.25.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 2/2] staging: greybus: audio: apbridgea: Fix reference counter leak in error handling
  2020-11-09 13:13 ` [PATCH 2/2] greybus: audio: apbridgea: " Zhang Qilong
@ 2020-11-13 23:27   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2020-11-13 23:27 UTC (permalink / raw)
  To: Zhang Qilong; +Cc: devel, elder, vaibhav.sr, johan, mgreer, greybus-dev

On Mon, Nov 09, 2020 at 09:13:47PM +0800, Zhang Qilong wrote:
> When gb_audio_apbridgea_register_cport failed, maybe:
> 
>   1) gb_pm_runtime_get_sync failed, usage counter remained unchanged;
> 
>   2) gb_hd_output failed, usage counter remained increased;
> 
> In error state, there are two different states in usage cpounter. So,
> if gb_hd_output failed, we should call gb_pm_runtime_put_autosuspend
> ot decrease usage counter for balabce preventing reference leak. And
> we fixed it by add gb_pm_runtime_put_autosuspend when gb_hd_output
> failed.
> 
> Fixes: 6ba7fad430d63 ("Add runtime pm support to audio protocol device class driver.")

That is not the name for that git commit id :(

Please fix up and resend.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2020-11-13 23:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 13:13 [PATCH 0/2] Fix reference counter leak in error banch Zhang Qilong
2020-11-09 13:13 ` [PATCH 1/2] staging: greybus: codecs: Fix reference counter leak in error handling Zhang Qilong
2020-11-09 13:13 ` [PATCH 2/2] greybus: audio: apbridgea: " Zhang Qilong
2020-11-13 23:27   ` [PATCH 2/2] staging: " Greg KH

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.