* [PATCH] platform/x86: lenovo: cancel fastcharger work on detach
@ 2026-08-06 6:05 Hongyan Xu
0 siblings, 0 replies; only message in thread
From: Hongyan Xu @ 2026-08-06 6:05 UTC (permalink / raw)
To: Mark Pearson, Derek J . Clark
Cc: Hans de Goede, Ilpo Järvinen, platform-driver-x86,
jianhao.xu, Hongyan Xu
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");
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-06 6:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 6:05 [PATCH] platform/x86: lenovo: cancel fastcharger work on detach Hongyan Xu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.