mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] platform/x86: lenovo: cancel fastcharger work on detach
       [not found] <20260806060526.1189-1-getshell@seu.edu.cn>
@ 2026-11-09 18:49 ` Ilpo Järvinen
  0 siblings, 0 replies; only message in thread
From: Ilpo Järvinen @ 2026-11-09 18:49 UTC (permalink / raw)
  To: Hongyan Xu, MyungJoo Ham, Chanwoo Choi
  Cc: Mark Pearson, Derek J . Clark, Hans de Goede,
	platform-driver-x86, jianhao.xu, LKML

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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-09 18:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20260806060526.1189-1-getshell@seu.edu.cn>
2026-11-09 18:49 ` [PATCH] platform/x86: lenovo: cancel fastcharger work on detach Ilpo Järvinen

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®