mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Hongyan Xu <getshell@seu.edu.cn>,
	sre@kernel.org, orsonzhai@gmail.com, zhang.lyra@gmail.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] power: supply: sc2731_charger: cancel work on remove
Date: Wed, 29 Jul 2026 11:43:41 +0800	[thread overview]
Message-ID: <ca1e30c2-ab03-407d-8a38-b7818c85ff8f@linux.alibaba.com> (raw)
In-Reply-To: <20260728123423.781-6-getshell@seu.edu.cn>



On 7/28/26 8:33 PM, Hongyan Xu wrote:
> The USB notifier and initial charger detection can schedule info->work.
> The remove path unregisters the notifier, but does not cancel queued or
> running work before the devm-allocated driver data is released.
> 
> Set the platform drvdata used by remove, then cancel the work after
> unregistering the notifier.
> 
> This issue was found by a static analysis tool.
> 
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> ---

Good catch. Please also add a Fixes tag, with that:
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

>   drivers/power/supply/sc2731_charger.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/power/supply/sc2731_charger.c b/drivers/power/supply/sc2731_charger.c
> index 58b86fd78..2b25e44da 100644
> --- a/drivers/power/supply/sc2731_charger.c
> +++ b/drivers/power/supply/sc2731_charger.c
> @@ -466,6 +466,7 @@ static int sc2731_charger_probe(struct platform_device *pdev)
>   	mutex_init(&info->lock);
>   	info->dev = &pdev->dev;
>   	INIT_WORK(&info->work, sc2731_charger_work);
> +	platform_set_drvdata(pdev, info);
>   
>   	info->regmap = dev_get_regmap(pdev->dev.parent, NULL);
>   	if (!info->regmap) {
> @@ -516,6 +517,7 @@ static void sc2731_charger_remove(struct platform_device *pdev)
>   	struct sc2731_charger_info *info = platform_get_drvdata(pdev);
>   
>   	usb_unregister_notifier(info->usb_phy, &info->usb_notify);
> +	cancel_work_sync(&info->work);
>   }
>   
>   static const struct of_device_id sc2731_charger_of_match[] = {


      reply	other threads:[~2026-07-29  3:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 12:33 Hongyan Xu
2026-07-29  3:43 ` Baolin Wang [this message]

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=ca1e30c2-ab03-407d-8a38-b7818c85ff8f@linux.alibaba.com \
    --to=baolin.wang@linux.alibaba.com \
    --cc=getshell@seu.edu.cn \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=orsonzhai@gmail.com \
    --cc=sre@kernel.org \
    --cc=zhang.lyra@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome