All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] media: uvc_video: fix bit overflow in uvc_probe_video
@ 2022-03-25  2:23 Hangyu Hua
  2022-03-25 15:37 ` Ricardo Ribalda
  0 siblings, 1 reply; 2+ messages in thread
From: Hangyu Hua @ 2022-03-25  2:23 UTC (permalink / raw)
  To: laurent.pinchart, mchehab; +Cc: linux-media, linux-kernel, Hangyu Hua

probe->dwMaxPayloadTransferSize is a 32bit value, but bandwidth is 16bit. This
may lead to a bit overflow.

Fix this by using probe->dwMaxPayloadTransferSize directly.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---

v2: 
Use probe->dwMaxPayloadTransferSize directly instead of changing temporary 
variable.

 drivers/media/usb/uvc/uvc_video.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 1b4cc934109e..e016f88bdf96 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -383,7 +383,6 @@ int uvc_probe_video(struct uvc_streaming *stream,
 	struct uvc_streaming_control *probe)
 {
 	struct uvc_streaming_control probe_min, probe_max;
-	u16 bandwidth;
 	unsigned int i;
 	int ret;
 
@@ -421,8 +420,7 @@ int uvc_probe_video(struct uvc_streaming *stream,
 		if (stream->intf->num_altsetting == 1)
 			break;
 
-		bandwidth = probe->dwMaxPayloadTransferSize;
-		if (bandwidth <= stream->maxpsize)
+		if (probe->dwMaxPayloadTransferSize <= stream->maxpsize)
 			break;
 
 		if (stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] media: uvc_video: fix bit overflow in uvc_probe_video
  2022-03-25  2:23 [PATCH v2] media: uvc_video: fix bit overflow in uvc_probe_video Hangyu Hua
@ 2022-03-25 15:37 ` Ricardo Ribalda
  0 siblings, 0 replies; 2+ messages in thread
From: Ricardo Ribalda @ 2022-03-25 15:37 UTC (permalink / raw)
  To: Hangyu Hua; +Cc: laurent.pinchart, mchehab, linux-media, linux-kernel

On Fri, 25 Mar 2022 at 16:34, Hangyu Hua <hbh25y@gmail.com> wrote:
>
> probe->dwMaxPayloadTransferSize is a 32bit value, but bandwidth is 16bit. This
> may lead to a bit overflow.
>
> Fix this by using probe->dwMaxPayloadTransferSize directly.
>
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>
> v2:
> Use probe->dwMaxPayloadTransferSize directly instead of changing temporary
> variable.
>
>  drivers/media/usb/uvc/uvc_video.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
> index 1b4cc934109e..e016f88bdf96 100644
> --- a/drivers/media/usb/uvc/uvc_video.c
> +++ b/drivers/media/usb/uvc/uvc_video.c
> @@ -383,7 +383,6 @@ int uvc_probe_video(struct uvc_streaming *stream,
>         struct uvc_streaming_control *probe)
>  {
>         struct uvc_streaming_control probe_min, probe_max;
> -       u16 bandwidth;
>         unsigned int i;
>         int ret;
>
> @@ -421,8 +420,7 @@ int uvc_probe_video(struct uvc_streaming *stream,
>                 if (stream->intf->num_altsetting == 1)
>                         break;
>
> -               bandwidth = probe->dwMaxPayloadTransferSize;
> -               if (bandwidth <= stream->maxpsize)
> +               if (probe->dwMaxPayloadTransferSize <= stream->maxpsize)
>                         break;
>
>                 if (stream->dev->quirks & UVC_QUIRK_PROBE_MINMAX) {
> --
> 2.25.1
>


-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-25 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25  2:23 [PATCH v2] media: uvc_video: fix bit overflow in uvc_probe_video Hangyu Hua
2022-03-25 15:37 ` Ricardo Ribalda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.