media: exynos4-is: Fix a race between s_stream(0) and the interrupt handler
Subsystems (4)
PATCH 1/1 media: exynos4-is: Fix a race between s_stream(0) and the interrupt handler
fimc_lite_subdev_s_stream(on = 0) sets ST_FLITE_OFF outside of the fimc->slock protected region and only then stops the capture in the hardware. flite_irq_handler() runs under fimc->slock and clears ST_FLITE_OFF, so an interrupt can be handled in between: the handler finds ST_FLITE_OFF already set, clears it and wakes up fimc->irq_queue before the capture has actually been stopped. The wait_event_timeout() right after it then returns immediately and the driver continues as if the capture had stopped.
Set ST_FLITE_OFF in the same critical section that stops the capture, as fimc_lite_stop_capture() already does.
--- drivers/media/platform/samsung/exynos4-is/fimc-lite.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/samsung/exynos4-is/fimc-lite.c +1 -2
@@ -1209,9 +1209,8 @@ static int fimc_lite_subdev_s_stream(struct v4l2_subdespin_unlock_irqrestore (&fimc->slock, flags); } }else { -set_bit (ST_FLITE_OFF , &fimc->state); -spin_lock_irqsave (&fimc->slock, flags); +set_bit (ST_FLITE_OFF , &fimc->state);flite_hw_capture_stop (fimc);spin_unlock_irqrestore (&fimc->slock, flags);
Signature · 1 line
2.43.0
Quoted 1 line
Fixes 6319d6a ("[media] fimc-lite: Add ISP FIFO output support")
Why did you specify a short hash for such a tag?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc4#n157
Regards,
Markus
PATCH v2 1/1 media: exynos4-is: Fix a race between s_stream(0) and the interrupt handler
In reply to Ginger Lifimc_lite_subdev_s_stream(on = 0) sets ST_FLITE_OFF outside of the fimc->slock protected region, and only then stops the capture in the hardware. flite_irq_handler() runs under fimc->slock and clears ST_FLITE_OFF, so an interrupt can be handled in between: the handler finds ST_FLITE_OFF already set, clears it and wakes up fimc->irq_queue before the capture has actually been stopped. The wait_event_timeout() right after it then returns immediately and the driver continues as if the capture had stopped.
Set ST_FLITE_OFF in the same critical section that stops the capture, as fimc_lite_stop_capture() already does.
---
v2:
- Fixes: expanded to 12 hex digits, as the media CI asks (the commit it points at is unchanged)
- Cc: [email protected] added; the bug goes back to a commit that is in stable releases
- commit message rewrapped to 75 columns
--- drivers/media/platform/samsung/exynos4-is/fimc-lite.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/samsung/exynos4-is/fimc-lite.c +1 -2
@@ -1209,9 +1209,8 @@ static int fimc_lite_subdev_s_stream(struct v4l2_subdespin_unlock_irqrestore (&fimc->slock, flags); } }else { -set_bit (ST_FLITE_OFF , &fimc->state); -spin_lock_irqsave (&fimc->slock, flags); +set_bit (ST_FLITE_OFF , &fimc->state);flite_hw_capture_stop (fimc);spin_unlock_irqrestore (&fimc->slock, flags);
Signature · 1 line
2.43.0