mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Hongyan Xu <getshell@seu.edu.cn>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	 Chanwoo Choi <cw00.choi@samsung.com>
Cc: Mark Pearson <mpearson-lenovo@squebb.ca>,
	 "Derek J . Clark" <derekjohn.clark@gmail.com>,
	 Hans de Goede <hansg@kernel.org>,
	platform-driver-x86@vger.kernel.org,  jianhao.xu@seu.edu.cn,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: lenovo: cancel fastcharger work on detach
Date: Mon, 9 Nov 2026 20:49:55 +0200 (EET)	[thread overview]
Message-ID: <2ef4ad43-497f-c40f-b18a-f5b75799d95d@linux.intel.com> (raw)
In-Reply-To: <20260806060526.1189-1-getshell@seu.edu.cn>

On Thu, 6 Aug 2026, Hongyan Xu wrote:

> The extcon notifier and probe queue yt2_1380_fc_worker(), which can sleep
> for several seconds while accessing managed pinctrl, GPIO and serdev
> resources. Driver detach does not drain this work before those resources
> are released, allowing the worker to use freed state.
> 
> Use devm_work_autocancel() between opening the managed serdev device and
> registering the managed notifier. Reverse devres release order then
> unregisters the notifier, cancels the work and only afterwards closes and
> releases the resources used by the worker.
> 
> Fixes: b2ed33e8d486 ("platform/x86: Add lenovo-yoga-tab2-pro-1380-fastcharger driver")
> Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
> ---
>  .../platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c    | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> index 8551ab4d2c7d..cce677b5db48 100644
> --- a/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> +++ b/drivers/platform/x86/lenovo/yoga-tab2-pro-1380-fastcharger.c
> @@ -8,6 +8,7 @@
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
>  #include <linux/delay.h>
> +#include <linux/devm-helpers.h>
>  #include <linux/err.h>
>  #include <linux/errno.h>
>  #include <linux/extcon.h>
> @@ -160,7 +161,6 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
>  
>  	fc->dev = dev;
>  	fc->nb.notifier_call = yt2_1380_fc_extcon_evt;
> -	INIT_WORK(&fc->work, yt2_1380_fc_worker);
>  
>  	/*
>  	 * Do this first since it may return -EPROBE_DEFER.
> @@ -209,6 +209,10 @@ static int yt2_1380_fc_serdev_probe(struct serdev_device *serdev)
>  	serdev_device_set_baudrate(serdev, 600);
>  	serdev_device_set_flow_control(serdev, false);
>  
> +	ret = devm_work_autocancel(dev, &fc->work, yt2_1380_fc_worker);
> +	if (ret)
> +		return ret;
> +
>  	ret = devm_extcon_register_notifier_all(dev, fc->extcon, &fc->nb);
>  	if (ret)
>  		return dev_err_probe(dev, ret, "registering extcon notifier\n");

While this looks an improvement from driver's perspective, sashiko is 
still worried extcon doesn't properly synchronize because it's using raw 
notifiers.

-- 
 i.


           reply	other threads:[~2026-11-09 18:50 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20260806060526.1189-1-getshell@seu.edu.cn>]

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=2ef4ad43-497f-c40f-b18a-f5b75799d95d@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=cw00.choi@samsung.com \
    --cc=derekjohn.clark@gmail.com \
    --cc=getshell@seu.edu.cn \
    --cc=hansg@kernel.org \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=myungjoo.ham@samsung.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®