media: usbtv: fix control-message timeouts
authorJohan Hovold <johan@kernel.org>
Mon, 13 Jan 2020 17:18:18 +0000 (18:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2020 13:28:21 +0000 (15:28 +0200)
commit 536f561d871c5781bc33d26d415685211b94032e upstream.

The driver was issuing synchronous uninterruptible control requests
without using a timeout. This could lead to the driver hanging on
various user requests due to a malfunctioning (or malicious) device
until the device is physically disconnected.

The USB upper limit of five seconds per request should be more than
enough.

Fixes: f3d27f34fdd7 ("[media] usbtv: Add driver for Fushicai USBTV007 video frame grabber")
Fixes: c53a846c48f2 ("[media] usbtv: add video controls")
Cc: stable <stable@vger.kernel.org> # 3.11
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Lubomir Rintel <lkundrak@v3.sk>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/usb/usbtv/usbtv-core.c
drivers/media/usb/usbtv/usbtv-video.c

index 5095c380b2c1a418bd301b1016101353d8b70475..ee9c656d121f120a2d056133f6137b3a4f6c1339 100644 (file)
@@ -56,7 +56,7 @@ int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
 
                ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG,
                        USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-                       value, index, NULL, 0, 0);
+                       value, index, NULL, 0, USB_CTRL_GET_TIMEOUT);
                if (ret < 0)
                        return ret;
        }
index 36a9a401718574fc7c8809934e035cc30b4eb546..6ff806ca43f5c450ba0c9aef037e04bbc6d341b0 100644 (file)
@@ -805,7 +805,8 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
                ret = usb_control_msg(usbtv->udev,
                        usb_rcvctrlpipe(usbtv->udev, 0), USBTV_CONTROL_REG,
                        USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-                       0, USBTV_BASE + 0x0244, (void *)data, 3, 0);
+                       0, USBTV_BASE + 0x0244, (void *)data, 3,
+                       USB_CTRL_GET_TIMEOUT);
                if (ret < 0)
                        goto error;
        }
@@ -856,7 +857,7 @@ static int usbtv_s_ctrl(struct v4l2_ctrl *ctrl)
        ret = usb_control_msg(usbtv->udev, usb_sndctrlpipe(usbtv->udev, 0),
                        USBTV_CONTROL_REG,
                        USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
-                       0, index, (void *)data, size, 0);
+                       0, index, (void *)data, size, USB_CTRL_SET_TIMEOUT);
 
 error:
        if (ret < 0)