From: sashiko-bot@kernel.org
To: "Keisuke Tsukuda" <tkdkei@outlook.jp>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH v2] usb: gadget: uvc: compute isoc payload size at encode time
Date: Wed, 02 Dec 2026 07:22:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-245058@kernel.org> (raw)
In-Reply-To: <20261202071552.5481-1-tkdkei@outlook.jp>
> uvc_buffer_prepare() calculates req_payload_size when userspace queues a
> buffer. Before the first STREAMON, reqs_per_frame is zero, so the payload
> size falls back to max_req_size. After the host selects streaming alt 1,
> this fallback can exceed the isochronous request size later allocated at
> STREAMON. If QBUF occurs before alt 1, max_req_size is still zero; the
> copying encoder then subtracts the UVC header length from a zero payload
> size. Either case can make it copy past the request buffer. A buffer
> queued before a later STREAMON can also use the previous stream's request
> layout because reqs_per_frame and req_size are not reset.
>
> On a Raspberry Pi CM4, a 320x180 YUYV stream with a 512-byte stored
> payload and 228-byte requests produced list_del corruption and an Oops.
>
> Calculate the payload size in uvcg_video_pump() instead, after the
> current request count and size have been set, and remove the prepare-time
> calculation. Bound the result by req_size. Round up with a quotient and
> remainder, then cap the data and header lengths before adding them to
> avoid 32-bit overflow.
>
> Fixes: 98ad03291560 ("usb: gadget: uvc: set req_length based on payload by nreqs instead of req_size")
> Fixes: 2edc1acb1a25 ("usb: gadget: uvc: fix req_payload_size calculation")
> Reported-by: Farhad Alemi <farhad.alemi@berkeley.edu>
> Closes: https://lore.kernel.org/r/CA+0ovCh5uOgB5CQm5eqZFoWE11Uqs4=t4yES-7E1_oH60HtaKw@mail.gmail.com
> Cc: stable@vger.kernel.org
> Signed-off-by: Keisuke Tsukuda <tkdkei@outlook.jp>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202071552.5481-1-tkdkei@outlook.jp?part=1
prev parent reply other threads:[~2026-12-02 7:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 7:15 [PATCH v2] usb: gadget: uvc: compute isoc payload size at encode time Keisuke Tsukuda
2026-12-02 7:22 ` sashiko-bot [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=sashiko-outbox-245058@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tkdkei@outlook.jp \
/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