diff mbox

[4/4] usb: gadget: uvc: disable stream when disconnected

Message ID c976dea958a834213a52ea36fdafffbcfafb2ba6.1524011428.git.paul.elder@pitt.edu (mailing list archive)
State New, archived
Headers show

Commit Message

Paul Elder April 18, 2018, 3:18 a.m. UTC
Down the call stack from the ioctl handler for VIDIOC_STREAMON,
uvc_video_alloc_requests contains a BUG_ON, which in the high level,
triggers when VIDIOC_STREAMON ioctl is issued without VIDIOC_STREAMOFF
being issued previously.

This can also be triggered by starting the stream and then physically
disconnecting usb. To fix this, do the streamoff procedures on usb
disconnect.

Signed-off-by: Paul Elder <paul.elder@pitt.edu>
---
 drivers/usb/gadget/function/f_uvc.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 3324d36e809c..e67f42ee2342 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -384,9 +384,12 @@  uvc_function_disable(struct usb_function *f)
 {
 	struct uvc_device *uvc = to_uvc(f);
 	struct v4l2_event v4l2_event;
+	struct uvc_video *video = &uvc->video;
 
 	INFO(f->config->cdev, "uvc_function_disable\n");
 
+	uvcg_video_enable(video, 0);
+
 	memset(&v4l2_event, 0, sizeof(v4l2_event));
 	v4l2_event.type = UVC_EVENT_DISCONNECT;
 	v4l2_event_queue(&uvc->vdev, &v4l2_event);