1 From 6641a47aee2349af02dbc8501f62519b2de15ada Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 2 Nov 2020 10:26:50 +0800
4 Subject: USB: apple-mfi-fastcharge: fix reference leak in
5 apple_mfi_fc_set_property
7 From: Zhang Qilong <zhangqilong3@huawei.com>
9 [ Upstream commit 00bd6bca3fb1e98190a24eda2583062803c9e8b5 ]
11 pm_runtime_get_sync() will increment pm usage at first and it
12 will resume the device later. If runtime of the device has
13 error or device is in inaccessible state(or other error state),
14 resume operation will fail. If we do not call put operation to
15 decrease the reference, the result is that this device cannot
16 enter the idle state and always stay busy or other non-idle
19 Fixes: 249fa8217b846 ("USB: Add driver to control USB fast charge for iOS devices")
20 Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
21 Link: https://lore.kernel.org/r/20201102022650.67115-1-zhangqilong3@huawei.com
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 Signed-off-by: Sasha Levin <sashal@kernel.org>
25 drivers/usb/misc/apple-mfi-fastcharge.c | 4 +++-
26 1 file changed, 3 insertions(+), 1 deletion(-)
28 diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
29 index 579d8c84de42c..9de0171b51776 100644
30 --- a/drivers/usb/misc/apple-mfi-fastcharge.c
31 +++ b/drivers/usb/misc/apple-mfi-fastcharge.c
32 @@ -120,8 +120,10 @@ static int apple_mfi_fc_set_property(struct power_supply *psy,
33 dev_dbg(&mfi->udev->dev, "prop: %d\n", psp);
35 ret = pm_runtime_get_sync(&mfi->udev->dev);
38 + pm_runtime_put_noidle(&mfi->udev->dev);
43 case POWER_SUPPLY_PROP_CHARGE_TYPE: