uvideo: fix step=0 infinite loop and int overflow in fbuf_size

Prevent infinite loop in uvideo_vs_negotiation() when a USB camera reports
step=0 in its continuous frame interval descriptor.
Cast fbuf_size calculation to uint64_t to avoid int overflow for large
width/height/bpp combinations.

Reported by:	emaste
This commit is contained in:
Baptiste Daroussin committed 2026-07-24 17:07:50 +02:00
1 parent 26bb78b772
commit 8468152509
1 file changed
+3 -1
+3 -1
View File
@@ -1744,7 +1744,7 @@ uvideo_vs_parse_desc_frame_buffer_size(struct uvideo_softc *sc,
* width * height * bpp since dwMaxVideoFrameBufferSize may be wrong.
*/
if (desc->bDescriptorSubtype == UDESCSUB_VS_FRAME_UNCOMPRESSED) {
fbuf_size = UGETW(fd->u.uc.wWidth) *
fbuf_size = (uint64_t)UGETW(fd->u.uc.wWidth) *
UGETW(fd->u.uc.wHeight) *
sc->sc_fmtgrp[fmtidx].format->u.uc.bBitsPerPixel / NBBY;
} else
@@ -2037,6 +2037,8 @@ uvideo_vs_negotiation(struct uvideo_softc *sc, int commit)
else if (frame_ival >= max)
frame_ival = max;
else {
if (step == 0)
step = 1;
for (i = min;
i + step / 2 < frame_ival;
i += step)