linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: apple-mfi-fastcharge: fix reference leak in apple_mfi_fc_set_property
@ 2020-10-30 15:45 Zhang Qilong
  2020-10-30 15:56 ` Bastien Nocera
  2020-10-30 18:11 ` Sergei Shtylyov
  0 siblings, 2 replies; 4+ messages in thread
From: Zhang Qilong @ 2020-10-30 15:45 UTC (permalink / raw)
  To: hadess; +Cc: gregkh, linux-usb

pm_runtime_get_sync() will increment pm usage counter even
it failed. Forgetting to call pm_runtime_put_noidle will
result in reference leak in apple_mfi_fc_set_property, so
we should fix it.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/usb/misc/apple-mfi-fastcharge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
index b403094a6b3a..9e1ad4536e36 100644
--- a/drivers/usb/misc/apple-mfi-fastcharge.c
+++ b/drivers/usb/misc/apple-mfi-fastcharge.c
@@ -120,8 +120,10 @@ static int apple_mfi_fc_set_property(struct power_supply *psy,
 	dev_dbg(&mfi->udev->dev, "prop: %d\n", psp);
 
 	ret = pm_runtime_get_sync(&mfi->udev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		pm_runtime_put_noidle(&mfi->udev->dev);
 		return ret;
+	}
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_CHARGE_TYPE:
-- 
2.17.1


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

end of thread, other threads:[~2020-10-31  3:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-30 15:45 [PATCH] USB: apple-mfi-fastcharge: fix reference leak in apple_mfi_fc_set_property Zhang Qilong
2020-10-30 15:56 ` Bastien Nocera
2020-10-31  3:29   ` 答复: " zhangqilong
2020-10-30 18:11 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).