[PATCH] media: cx88: guard against empty active list in cx88_wakeup()

From: Ziheng Wei

Date: Mon Nov 30 2026 - 05:33:47 EST


cx88_wakeup() calls list_entry(q->active.next, struct cx88_buffer, list),
unlinks it, and calls vb2_buffer_done() without checking whether q->active
is empty. Because stop_streaming() drains dmaq->active without masking
MO_VID_INTMSK or synchronizing the IRQ, a racing or trailing risc1
interrupt can invoke cx88_wakeup() on an empty queue and corrupt the
owning device struct via a bogus container_of() pointer.

Return early from cx88_wakeup() when q->active is empty.

Found by LLM-assisted static analysis and compile-tested on x86_64.

Signed-off-by: Ziheng Wei <zihengw03@xxxxxxx>
---
drivers/media/pci/cx88/cx88-core.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index 52be42f9a..691266d64 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -522,6 +522,9 @@ void cx88_wakeup(struct cx88_core *core,
{
struct cx88_buffer *buf;

+ if (list_empty(&q->active))
+ return;
+
buf = list_entry(q->active.next,
struct cx88_buffer, list);
buf->vb.vb2_buf.timestamp = ktime_get_ns();

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
--
2.43.0