[PATCH 2/2] greybus: audio: apbridgea: Fix reference counter leak in error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux