And regarding the magic number, it should be based on dwMaxVideoFrameBufferSize, not on frame->wWidth , frame->wHeight (if we decide to have a magic number). or even better, we could have min_dwFrameInterval. > > >> + if (format->flags & UVC_FMT_FLAG_COMPRESSED) { > >> + u32 bandwidth; > >> + > >> + if (!stream->dev->info->max_bandwidth || !frame->bFrameIntervalType) > >> + return; > >> + > >> + for (i = 0; i < frame->bFrameIntervalType; ++i) { > >> + bandwidth = frame->wWidth * frame->wHeight; > >> + bandwidth *= UVC_FIVAL_DENOM / frame->dwFrameInterval[i]; > > > > frame->dwFrameInterval[i] comes from the device, it is not sanitized. > > We need to make sure it is not zero. > > That is a good point, in the non-compressed UVC_QUIRK_FIX_BANDWIDTH handling > this is handled by doing: > > bandwidth *= UVC_FIVAL_DENOM / (frame->dwFrameInterval[i] + 1); > > I guess we should do the same here then ? I prefer (max(1,frame->dwFrameInterval[i]) But you chose :) > > Regards, > > Hans > > > > > > >> + > >> + if (bandwidth <= stream->dev->info->max_bandwidth) > >> + break; > >> + } > >> + > >> + if (ctrl->dwFrameInterval < frame->dwFrameInterval[i]) > >> + ctrl->dwFrameInterval = frame->dwFrameInterval[i]; > >> + > >> + return; > >> + } > >> + > >> + if (stream->intf->num_altsetting > 1) { > >> u32 interval; > >> u32 bandwidth; > >> > >> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h > >> index 966ff82c2ba8..6b702219173f 100644 > >> --- a/drivers/media/usb/uvc/uvcvideo.h > >> +++ b/drivers/media/usb/uvc/uvcvideo.h > >> @@ -535,6 +535,7 @@ static inline u32 uvc_urb_index(const struct uvc_urb *uvc_urb) > >> > >> struct uvc_device_info { > >> u32 quirks; > >> + u32 max_bandwidth; /* In pixels per second */ > >> u32 meta_format; > >> u16 uvc_version; > >> }; > >> -- > >> 2.47.1 > >> > >> > > > > > -- Ricardo Ribalda