* [PATCH v5 06/15] media: sunxi-cir: Ensure no more interrupts can occur before free
[not found] <cover.1785338381.git.sean@mess.org>
@ 2026-07-29 15:22 ` Sean Young
2026-07-29 15:31 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Sean Young @ 2026-07-29 15:22 UTC (permalink / raw)
To: linux-media, Sean Young, Mauro Carvalho Chehab, Chen-Yu Tsai,
Jernej Skrabec, Samuel Holland, Patrice Chotard, Hans Verkuil
Cc: stable, linux-arm-kernel, linux-sunxi, linux-kernel
Only call rc_free_device() once the hardware has been stopped.
Fixes: dccc0c3ddf8f ("media: rc: fix race between unregister and urb/irq callbacks")
Signed-off-by: Sean Young <sean@mess.org>
Cc: stable@vger.kernel.org
---
drivers/media/rc/sunxi-cir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
index 28e840a7e5b8..af1ee08ffdbe 100644
--- a/drivers/media/rc/sunxi-cir.c
+++ b/drivers/media/rc/sunxi-cir.c
@@ -374,8 +374,8 @@ static void sunxi_ir_remove(struct platform_device *pdev)
struct sunxi_ir *ir = platform_get_drvdata(pdev);
rc_unregister_device(ir->rc);
- rc_free_device(ir->rc);
sunxi_ir_hw_exit(&pdev->dev);
+ rc_free_device(ir->rc);
}
static void sunxi_ir_shutdown(struct platform_device *pdev)
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v5 06/15] media: sunxi-cir: Ensure no more interrupts can occur before free
2026-07-29 15:22 ` [PATCH v5 06/15] media: sunxi-cir: Ensure no more interrupts can occur before free Sean Young
@ 2026-07-29 15:31 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-29 15:31 UTC (permalink / raw)
To: Sean Young; +Cc: linux-sunxi, media-ci
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The teardown race between `sunxi_ir_remove()` and `sunxi_ir_irq()` is not resolved by the patch. The interrupt remains active and unsynchronized while clocks are disabled and memory is freed, leading to synchronous external aborts and use-after-free vulnerabilities. A similar issue exists in `probe()` where the IRQ is requested before clocks are enabled.
--
--- Patch [6]: [PATCH v5 06/15] media: sunxi-cir: Ensure no more interrupts can occur before free ---
commit 485344025b667511dbe1afe16a5fb9cab1f312f6
Author: Sean Young <sean@mess.org>
media: sunxi-cir: Ensure no more interrupts can occur before free
This commit delays rc_free_device() until after sunxi_ir_hw_exit() in the
remove path. It attempts to ensure the hardware is stopped and no further
interrupts can occur before the device memory is freed.
Cc: stable@vger.kernel.org
> diff --git a/drivers/media/rc/sunxi-cir.c b/drivers/media/rc/sunxi-cir.c
> index 28e840a7e5b8c..af1ee08ffdbec 100644
> --- a/drivers/media/rc/sunxi-cir.c
> +++ b/drivers/media/rc/sunxi-cir.c
> @@ -374,8 +374,8 @@ static void sunxi_ir_remove(struct platform_device *pdev)
> struct sunxi_ir *ir = platform_get_drvdata(pdev);
>
> rc_unregister_device(ir->rc);
> - rc_free_device(ir->rc);
> sunxi_ir_hw_exit(&pdev->dev);
> + rc_free_device(ir->rc);
[Severity: High]
This is a pre-existing issue, but does this actually prevent interrupts from
occurring before the free?
The driver requests the IRQ via devm_request_irq() in sunxi_ir_probe(), which
means the IRQ is not freed or synchronized until devres cleanup runs after
sunxi_ir_remove() returns.
While sunxi_ir_hw_exit() disables the APB clock, it does not explicitly disable
or synchronize the IRQ handler. If an interrupt executes concurrently, can it
fault when reading unclocked MMIO registers?
drivers/media/rc/sunxi-cir.c:sunxi_ir_irq() {
...
status = readl(ir->base + SUNXI_IR_RXSTA_REG);
...
ir_raw_event_store_with_filter(ir->rc, &rawir);
}
Because the IRQ handler is unsynchronized, could it also dereference the freed
ir->rc if it races with or runs after rc_free_device()?
Additionally, is there a similar window in sunxi_ir_probe()?
drivers/media/rc/sunxi-cir.c:sunxi_ir_probe() {
...
ret = devm_request_irq(dev, ir->irq, sunxi_ir_irq, 0, SUNXI_IR_DEV, ir);
...
ret = sunxi_ir_hw_init(dev);
...
}
The IRQ handler is requested and enabled before sunxi_ir_hw_init() enables
the APB clock. Could a pending interrupt trigger the handler and access
unclocked registers during boot?
> }
>
> static void sunxi_ir_shutdown(struct platform_device *pdev)
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1785338381.git.sean@mess.org?part=6
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-29 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1785338381.git.sean@mess.org>
2026-07-29 15:22 ` [PATCH v5 06/15] media: sunxi-cir: Ensure no more interrupts can occur before free Sean Young
2026-07-29 15:31 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox