Skip to contentSkip to conversation

rtc: mxc_v2: fix clock-unprepare race with the still-live alarm IRQ

PATCH New Cong Nguyen 2 participants 2 messages Sep 18

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

PATCH 1/1 rtc: mxc_v2: fix clock-unprepare race with the still-live alarm IRQ

remove() unprepares the clock, but the alarm IRQ is devm-managed and only actually freed after remove() returns -- so it's still live while the clock is unprepared. If it fires in that window, mxc_rtc_interrupt() calls clk_enable() on an unprepared clock.

Free the IRQ explicitly in remove(), before touching the clock, so it can't fire during or after the unprepare.

Fixes 55d5a86618d3 ("rtc: mxc_v2: Add missing clk_disable_unprepare()")
Assisted-by LLM
---
 drivers/rtc/rtc-mxc_v2.c | 1 +
 1 file changed, 1 insertion(+)
drivers/rtc/rtc-mxc_v2.c +1 -0
index a07acbbcfaeb..3c174f6004c5 100644
@@ -365,6 +365,7 @@ static void mxc_rtc_remove(struct platform_device *pdev)
 {
 	struct mxc_rtc_data *pdata = platform_get_drvdata(pdev);
 
+	devm_free_irq(&pdev->dev, pdata->irq, &pdev->dev);
 	clk_disable_unprepare(pdata->clk);
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

remove() unprepares the clock, but the alarm IRQ is devm-managed and only actually freed after remove() returns -- so it's still live while the clock is unprepared. If it fires in that window, mxc_rtc_interrupt() calls clk_enable() on an unprepared clock.

Quoted 8 lines

Free the IRQ explicitly in remove(), before touching the clock, so it can't fire during or after the unprepare.

Fixes 55d5a86618d3 ("rtc: mxc_v2: Add missing clk_disable_unprepare()")
Assisted-by LLM

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1