All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/2] greybus: audio: apbridgea: Fix reference counter leak in error handling
@ 2020-11-14  3:17 Zhang Qilong
  0 siblings, 0 replies; only message in thread
From: Zhang Qilong @ 2020-11-14  3:17 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 ("greybus: audio: add runtime pm support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
Changelog:
v2
- fix the name for fixed commit id
---
 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] only message in thread

only message in thread, other threads:[~2020-11-14  3:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14  3:17 [PATCH v2 2/2] greybus: audio: apbridgea: Fix reference counter leak in error handling Zhang Qilong

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.