All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Qilong <zhangqilong3@huawei.com>
To: <vaibhav.sr@gmail.com>, <mgreer@animalcreek.com>,
	<johan@kernel.org>, <elder@kernel.org>,
	<gregkh@linuxfoundation.org>
Cc: devel@driverdev.osuosl.org, greybus-dev@lists.linaro.org
Subject: [PATCH 2/2] greybus: audio: apbridgea: Fix reference counter leak in error handling
Date: Mon, 9 Nov 2020 21:13:47 +0800	[thread overview]
Message-ID: <20201109131347.1725288-3-zhangqilong3@huawei.com> (raw)
In-Reply-To: <20201109131347.1725288-1-zhangqilong3@huawei.com>

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

  parent reply	other threads:[~2020-11-09 13:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-11-13 23:27   ` [PATCH 2/2] staging: greybus: audio: apbridgea: " Greg KH

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=20201109131347.1725288-3-zhangqilong3@huawei.com \
    --to=zhangqilong3@huawei.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=mgreer@animalcreek.com \
    --cc=vaibhav.sr@gmail.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 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.