Skip to contentSkip to conversation

media: uvc_video: fix bit overflow in uvc_probe_video

PATCH In review Hangyu Hua 2 participants 2 messages Mar 25, 2022

Subsystems (2)
lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH v2 1/1 media: uvc_video: fix bit overflow in uvc_probe_video

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

Fix this by using probe->dwMaxPayloadTransferSize directly.

---

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(-)
drivers/media/usb/uvc/uvc_video.c +1 -3
index 1b4cc934109e..e016f88bdf96 100644
@@ -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) {
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · 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.

Quoted 34 lines

---

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(-)
drivers/media/usb/uvc/uvc_video.c +1 -4
index 1b4cc934109e..e016f88bdf96 100644
@@ -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

Signature · 1 line
Ricardo Ribalda