[PATCH] media: usb: em28xx: check if vbi is supported before calling, vb2_queue_init

Hans Verkuil <[email protected]> Fri, 31 Jul 2026 12:36:52 +0200
Newsgroups org.kernel.vger.linux-media
Message-ID <[email protected]>
If the device does not support vbi, then the vbi queue is still
initialized with vb2_queue_init(), which fails with a WARNing because
the q->lock pointer is never set.

Only call vb2_queue_init for the vbi queue if vbi is actually
supported.

Signed-off-by: Hans Verkuil <[email protected]>
Tested-by: Hans Verkuil <[email protected]>
Reported-by: Lars Ljung <[email protected]>
Closes: https://lore.kernel.org/linux-media/[email protected]/T/#u
---
 drivers/media/usb/em28xx/em28xx-video.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index c418add65bb5..3e72d9613dd2 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1410,6 +1410,9 @@ static int em28xx_vb2_setup(struct em28xx *dev)
 	if (rc < 0)
 		return rc;

+	if (!em28xx_vbi_supported(dev))
+		return 0;
+
 	/* Setup Videobuf2 for VBI capture */
 	q = &v4l2->vb_vbiq;
 	q->type = V4L2_BUF_TYPE_VBI_CAPTURE;
-- 
2.53.0