Skip to content

Commit

Permalink
USB: apple-mfi-fastcharge: fix reference leak in apple_mfi_fc_set_pro…
Browse files Browse the repository at this point in the history
…perty

pm_runtime_get_sync() will increment pm usage at first and it
will resume the device later. If runtime of the device has
error or device is in inaccessible state(or other error state),
resume operation will fail. If we do not call put operation to
decrease the reference, the result is that this device cannot
enter the idle state and always stay busy or other non-idle
state.

Fixes: 249fa82 ("USB: Add driver to control USB fast charge for iOS devices")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Link: https://lore.kernel.org/r/20201102022650.67115-1-zhangqilong3@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Zhang Qilong authored and Greg Kroah-Hartman committed Nov 6, 2020
1 parent 2091491 commit 00bd6bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/misc/apple-mfi-fastcharge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 00bd6bc

Please sign in to comment.