From: Bastien Nocera <hadess@hadess.net>
To: Zhang Qilong <zhangqilong3@huawei.com>
Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH] USB: apple-mfi-fastcharge: fix reference leak in apple_mfi_fc_set_property
Date: Fri, 30 Oct 2020 16:56:36 +0100 [thread overview]
Message-ID: <0145bd8636cb9f384e5e9b7149a7d9a90bc56825.camel@hadess.net> (raw)
In-Reply-To: <20201030154534.98294-1-zhangqilong3@huawei.com>
On Fri, 2020-10-30 at 23:45 +0800, Zhang Qilong wrote:
> 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>
It looks correct, but I don't know whether it's necessary.
There's a boatload of users of that API that don't even check for the
get_sync() retval, and loads more where it's checked but never acted
upon.
Do you intend to fix all those as well?
> ---
> 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:
next prev parent reply other threads:[~2020-10-30 15:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-10-31 3:29 ` 答复: " zhangqilong
2020-10-30 18:11 ` Sergei Shtylyov
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=0145bd8636cb9f384e5e9b7149a7d9a90bc56825.camel@hadess.net \
--to=hadess@hadess.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=zhangqilong3@huawei.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 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).