The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] extcon: lc824206xa: cancel work on driver detach
@ 2026-08-06  6:04 Hongyan Xu
  0 siblings, 0 replies; only message in thread
From: Hongyan Xu @ 2026-08-06  6:04 UTC (permalink / raw)
  To: MyungJoo Ham, Chanwoo Choi; +Cc: linux-kernel, jianhao.xu, Hongyan Xu

The IRQ handler and probe both queue lc824206xa_work(). The worker accesses
driver data and managed extcon, power supply and regulator resources.
Without cancellation, it can run after those resources are released on
driver detach.

Use devm_work_autocancel() after registering the resources used by the
worker and before requesting the managed IRQ. Reverse devres release order
then frees the IRQ first, cancels the work next and releases its
dependencies last.

Fixes: 9e1897cb9568 ("extcon: Add LC824206XA microUSB switch driver")
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
---
 drivers/extcon/extcon-lc824206xa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-lc824206xa.c b/drivers/extcon/extcon-lc824206xa.c
index 56938748aea8..f4da4942e6fe 100644
--- a/drivers/extcon/extcon-lc824206xa.c
+++ b/drivers/extcon/extcon-lc824206xa.c
@@ -18,6 +18,7 @@
 
 #include <linux/bits.h>
 #include <linux/delay.h>
+#include <linux/devm-helpers.h>
 #include <linux/device.h>
 #include <linux/extcon-provider.h>
 #include <linux/i2c.h>
@@ -424,7 +425,6 @@ static int lc824206xa_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	data->client = client;
-	INIT_WORK(&data->work, lc824206xa_work);
 	data->cable = EXTCON_NONE;
 	data->previous_cable = EXTCON_NONE;
 	data->usb_type = POWER_SUPPLY_USB_TYPE_UNKNOWN;
@@ -463,6 +463,10 @@ static int lc824206xa_probe(struct i2c_client *client)
 	if (IS_ERR(data->psy))
 		return dev_err_probe(dev, PTR_ERR(data->psy), "registering power supply\n");
 
+	ret = devm_work_autocancel(dev, &data->work, lc824206xa_work);
+	if (ret)
+		return ret;
+
 	ret = devm_request_threaded_irq(dev, client->irq, NULL, lc824206xa_irq,
 					IRQF_TRIGGER_LOW | IRQF_ONESHOT,
 					KBUILD_MODNAME, data);
-- 
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:04 [PATCH] extcon: lc824206xa: cancel work on driver detach Hongyan Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox