From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: zhangdaolong <dlzhangak@isoftstone.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Antti Palosaari <crope@iki.fi>,
Valery Borovsky <vebohr@gmail.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+930e6201080a31e9d0c8@syzkaller.appspotmail.com,
stable@vger.kernel.org
Subject: Re: [PATCH] media: msi2500: return buffers as QUEUED in buf_queue() before start_streaming()
Date: Wed, 11 Nov 2026 13:29:13 +0100 [thread overview]
Message-ID: <dc4b0511-56a6-4510-a4b7-311906c9fd69@kernel.org> (raw)
In-Reply-To: <1793954471.6AED92A4.003.4jLXhN6Cksz4Dr7@fangwg01>
On 06/11/2026 09:41, zhangdaolong wrote:
> When vb2_start_streaming() is invoked, it first passes all pre-queued
> buffers on q->queued_list to the driver via buf_queue() before setting
> q->start_streaming_called and invoking start_streaming(). If
> start_streaming() subsequently returns an error, videobuf2 requires all
> buffers passed to the driver to be returned with VB2_BUF_STATE_QUEUED
> and warns via WARN_ON(!list_empty(&q->done_list)) if any buffer was
> completed with VB2_BUF_STATE_ERROR or VB2_BUF_STATE_DONE.
>
> If the USB device disconnects before vb2_start_streaming() runs (for
> example when v4l2_read() races with msi2500_disconnect()), dev->udev is
> already NULL when vb2_start_streaming() enters. msi2500_buf_queue() sees
> !dev->udev and immediately completes each pre-queued buffer with
> VB2_BUF_STATE_ERROR (moving it onto q->done_list) instead of adding it
> to dev->queued_bufs. Right after that, msi2500_start_streaming() also
> sees !dev->udev and returns -ENODEV, triggering
> WARN_ON(!list_empty(&q->done_list)) in vb2_start_streaming().
>
> Fix this by checking vb2_start_streaming_called(vb->vb2_queue) in
> msi2500_buf_queue() when !dev->udev: return VB2_BUF_STATE_QUEUED when
> start_streaming() has not been called yet, and VB2_BUF_STATE_ERROR when
> streaming is already active.
>
> Reported-by: syzbot+930e6201080a31e9d0c8@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=930e6201080a31e9d0c8
> Fixes: 977e444f59ad ("[media] Mirics MSi3101 SDR Dongle driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: zhangdaolong <dlzhangak@isoftstone.com>
> ---
> drivers/media/usb/msi2500/msi2500.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
> index 282256ab812a..d89db57f924f 100644
> --- a/drivers/media/usb/msi2500/msi2500.c
> +++ b/drivers/media/usb/msi2500/msi2500.c
> @@ -625,7 +625,9 @@ static void msi2500_buf_queue(struct vb2_buffer *vb)
>
> /* Check the device has not disconnected between prep and queuing */
> if (unlikely(!dev->udev)) {
> - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
> + vb2_buffer_done(&buf->vb.vb2_buf,
> + vb2_start_streaming_called(vb->vb2_queue) ?
> + VB2_BUF_STATE_ERROR : VB2_BUF_STATE_QUEUED);
> return;
> }
I think the real problem is that msi2500_buf_queue is calling vb2_buffer_done
at all.
What happens if you just remove this 'if' completely?
I don't think I have seen vb2_buffer_done being called from buf_queue before.
It's very dubious code.
Regards,
Hans
>
prev parent reply other threads:[~2026-11-11 12:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 8:41 zhangdaolong
2026-11-11 12:29 ` Hans Verkuil [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dc4b0511-56a6-4510-a4b7-311906c9fd69@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=crope@iki.fi \
--cc=dlzhangak@isoftstone.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+930e6201080a31e9d0c8@syzkaller.appspotmail.com \
--cc=vebohr@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®