]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
media: uvcvideo: Fix allocation for small frame sizes
authorRicardo Ribalda <ribalda@chromium.org>
Wed, 14 Jan 2026 10:32:13 +0000 (10:32 +0000)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 22 Jan 2026 07:18:51 +0000 (08:18 +0100)
commit40d3ac25c11310bfaa50ed7614846ef75cb69a1e
treeb8a983510fc4326d423ec7114288ffcb742ea4d0
parent4cf3b6fd54ebb1ebc977bdc47fb6cfcf9a471a22
media: uvcvideo: Fix allocation for small frame sizes

If a frame has size of less or equal than one packet size
uvc_alloc_urb_buffers() is unable to allocate memory for it due to a
off-by-one error.

Fix the off-by-one-error and now that we are at it, make sure that
stream->urb_size has always a valid value when we return from the
function, even when an error happens.

Fixes: efdc8a9585ce ("V4L/DVB (10295): uvcvideo: Retry URB buffers allocation when the system is low on memory.")
Reported-by: Itay Chamiel <itay.chamiel@q.ai>
Closes: https://lore.kernel.org/linux-media/CANiDSCsSoZf2LsCCoWAUbCg6tJT-ypXR1B85aa6rAdMVYr2iBQ@mail.gmail.com/T/#t
Co-developed-by: Itay Chamiel <itay.chamiel@q.ai>
Signed-off-by: Itay Chamiel <itay.chamiel@q.ai>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Itay Chamiel <itay.chamiel@q.ai>
Link: https://patch.msgid.link/20260114-uvc-alloc-urb-v1-1-cedf3fb66711@chromium.org
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/usb/uvc/uvc_video.c