Skip to contentSkip to conversation

extcon: int3496: cancel ID work before releasing dependencies

PATCH New Myeonghun Pak 1 participant 1 message Oct 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extcon: int3496: cancel ID work before releasing dependencies

The managed delayed-work cancellation is registered before the GPIO, regulator, and extcon resources used by the work. Devres can release those resources while queued work still runs.

Register work cancellation after its dependencies but before the IRQ that schedules it. Cleanup then frees the IRQ, cancels the work, and releases the dependent resources.

The teardown ordering issue was found by static analysis.

Fixes f94a5becabf4 ("extconn: Clean-up few drivers by using managed work init")
Assisted-by LLM
---
 drivers/extcon/extcon-intel-int3496.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/extcon/extcon-intel-int3496.c +4 -4
index 7d16d5b7d58f..13c585d978f2 100644
@@ -130,10 +130,6 @@ static int int3496_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	data->dev = dev;
-	ret = devm_delayed_work_autocancel(dev, &data->work, int3496_do_usb_id);
-	if (ret)
-		return ret;
-
 	data->gpio_usb_id =
 		devm_gpiod_get(dev, "id", GPIOD_IN | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
 	if (IS_ERR(data->gpio_usb_id)) {
@@ -169,6 +165,10 @@ static int int3496_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	ret = devm_delayed_work_autocancel(dev, &data->work, int3496_do_usb_id);
+	if (ret)
+		return ret;
+
 	ret = devm_request_threaded_irq(dev, data->usb_id_irq,
 					NULL, int3496_thread_isr,
 					IRQF_SHARED | IRQF_ONESHOT |