From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH] media: vivid: check vb2_is_busy before calling vivid_update_format_cap/out
Date: Wed, 13 May 2026 14:49:09 +0200 [thread overview]
Message-ID: <59f36548-06b7-452a-810b-96e5b25e5573@kernel.org> (raw)
In-Reply-To: <3016ee7c-9a4f-4fcf-b17f-0dce5bbc9260@kernel.org>
On 13/05/2026 10:52, Hans Verkuil wrote:
> The vivid_update_format_cap/out() functions must only be called if the
> capture/output queue are not busy. But for several controls that is not
> checked.
>
> Only when streaming starts will they be set to 'grabbed' and it is
> impossible to change the control, but between REQBUFS and STREAMON you
> are still allowed to set these controls. Since vivid_update_format_cap/out
> will change the format, this can cause unexpected results.
>
> I suspect that this is the cause of this syzbot bug:
>
> https://syzkaller.appspot.com/bug?extid=dac8f5eaa46837e97b89
>
> But since we never have reproducers, it is hard to be certain. In any case,
> these checks are needed regardless.
>
> Reported-by: syzbot+dac8f5eaa46837e97b89@syzkaller.appspotmail.com
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Oops, this should be Hans Verkuil <hverkuil+cisco@kernel.org>. Also add:
Fixes: c79aa6aeadb0 ("[media] vivid-capture: add control for reduced frame rate")
Cc: stable@vger.kernel.org
Regards,
Hans
> ---
> diff --git a/drivers/media/test-drivers/vivid/vivid-ctrls.c b/drivers/media/test-drivers/vivid/vivid-ctrls.c
> index f94c15ff84f7..e40ff999cad8 100644
> --- a/drivers/media/test-drivers/vivid/vivid-ctrls.c
> +++ b/drivers/media/test-drivers/vivid/vivid-ctrls.c
> @@ -608,18 +608,26 @@ static int vivid_vid_cap_s_ctrl(struct v4l2_ctrl *ctrl)
> tpg_s_vflip(&dev->tpg, dev->sensor_vflip ^ dev->vflip);
> break;
> case VIVID_CID_REDUCED_FPS:
> + if (vb2_is_busy(&dev->vb_vid_cap_q))
> + return -EBUSY;
> dev->reduced_fps = ctrl->val;
> vivid_update_format_cap(dev, true);
> break;
> case VIVID_CID_HAS_CROP_CAP:
> + if (vb2_is_busy(&dev->vb_vid_cap_q))
> + return -EBUSY;
> dev->has_crop_cap = ctrl->val;
> vivid_update_format_cap(dev, true);
> break;
> case VIVID_CID_HAS_COMPOSE_CAP:
> + if (vb2_is_busy(&dev->vb_vid_cap_q))
> + return -EBUSY;
> dev->has_compose_cap = ctrl->val;
> vivid_update_format_cap(dev, true);
> break;
> case VIVID_CID_HAS_SCALER_CAP:
> + if (vb2_is_busy(&dev->vb_vid_cap_q))
> + return -EBUSY;
> dev->has_scaler_cap = ctrl->val;
> vivid_update_format_cap(dev, true);
> break;
> @@ -1116,14 +1124,20 @@ static int vivid_vid_out_s_ctrl(struct v4l2_ctrl *ctrl)
>
> switch (ctrl->id) {
> case VIVID_CID_HAS_CROP_OUT:
> + if (vb2_is_busy(&dev->vb_vid_out_q))
> + return -EBUSY;
> dev->has_crop_out = ctrl->val;
> vivid_update_format_out(dev);
> break;
> case VIVID_CID_HAS_COMPOSE_OUT:
> + if (vb2_is_busy(&dev->vb_vid_out_q))
> + return -EBUSY;
> dev->has_compose_out = ctrl->val;
> vivid_update_format_out(dev);
> break;
> case VIVID_CID_HAS_SCALER_OUT:
> + if (vb2_is_busy(&dev->vb_vid_out_q))
> + return -EBUSY;
> dev->has_scaler_out = ctrl->val;
> vivid_update_format_out(dev);
> break;
>
next prev parent reply other threads:[~2026-05-13 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 8:52 [PATCH] media: vivid: check vb2_is_busy before calling vivid_update_format_cap/out Hans Verkuil
2026-05-13 12:49 ` Hans Verkuil [this message]
2026-05-13 14:59 ` Nicolas Dufresne
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=59f36548-06b7-452a-810b-96e5b25e5573@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=linux-media@vger.kernel.org \
/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