Skip to contentSkip to conversation

backlight: lm3630a: Cancel delayed work before destroying workqueue

PATCH Applied Myeonghun Pak 3 participants 3 messages Oct 3 – Oct 14

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

PATCH 1/1 backlight: lm3630a: Cancel delayed work before destroying workqueue

The interrupt handler queues delayed work to read the interrupt status. After free_irq() stops the producer, this work can still be waiting on its timer. destroy_workqueue() cannot drain delayed work that has not yet been queued by its timer, so the timer can outlive both the workqueue and the devm-allocated chip containing the work.

Cancel the delayed work synchronously after freeing the IRQ and before destroying the workqueue. This also waits for any running status read to finish before the chip's resources are released.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 0c2a665a648e ("backlight: add Backlight driver for lm3630 chip")
Assisted-by LLM
---
 drivers/video/backlight/lm3630a_bl.c | 1 +
 1 file changed, 1 insertion(+)
drivers/video/backlight/lm3630a_bl.c +1 -0
index 8f49e59ce374..8ef8163c7fef 100644
@@ -591,6 +591,7 @@ static void lm3630a_remove(struct i2c_client *client)
 
 	if (pchip->irq) {
 		free_irq(pchip->irq, pchip);
+		cancel_delayed_work_sync(&pchip->work);
 		destroy_workqueue(pchip->irqthread);
 	}
 }
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Myeonghun Pak

The interrupt handler queues delayed work to read the interrupt status. After free_irq() stops the producer, this work can still be waiting on its timer. destroy_workqueue() cannot drain delayed work that has not yet been queued by its timer, so the timer can outlive both the workqueue and the devm-allocated chip containing the work.

Cancel the delayed work synchronously after freeing the IRQ and before destroying the workqueue. This also waits for any running status read to finish before the chip's resources are released.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Quoted 6 lines
Fixes 0c2a665a648e ("backlight: add Backlight driver for lm3630 chip")
Assisted-by LLM

Daniel.

maintainer Applied
#2 lore raw

Re: (subset) [PATCH] backlight: lm3630a: Cancel delayed work before destroying workqueue

In reply to Myeonghun Pak
Quoted 11 lines · Myeonghun Pak

The interrupt handler queues delayed work to read the interrupt status. After free_irq() stops the producer, this work can still be waiting on its timer. destroy_workqueue() cannot drain delayed work that has not yet been queued by its timer, so the timer can outlive both the workqueue and the devm-allocated chip containing the work.

Cancel the delayed work synchronously after freeing the IRQ and before destroying the workqueue. This also waits for any running status read to finish before the chip's resources are released.

[...]

Applied, thanks!

[1/1] backlight: lm3630a: Cancel delayed work before destroying workqueue

      commit: 2cf184caab8b406fdd9db126ee40d62418237456

--
Lee Jones [李琼斯]