usb: gadget: uvc: Fix error handling in uvc_queue_buffer()
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 29 Apr 2013 20:18:01 +0000 (22:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Sep 2013 00:18:12 +0000 (17:18 -0700)
commit ebe864a6cb8e087ede047fa1fa6b6d06fcb9a9e4 upstream.

The conversion to videobuf2 failed to check the return value of
vb2_qbuf(). Fix it.

Reported-by: Michael Grzeschik <mgr@pengutronix.de>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-By: Michael Grzeschik <mgr@pengutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/uvc_queue.c

index 7ce27e35550b7e50c887764b53f6907e4fc5864d..de456a5a5e0a52ed6fcac1ca97ce64b5c3f0a336 100644 (file)
@@ -177,12 +177,16 @@ static int uvc_queue_buffer(struct uvc_video_queue *queue,
 
        mutex_lock(&queue->mutex);
        ret = vb2_qbuf(&queue->queue, buf);
+       if (ret < 0)
+               goto done;
+
        spin_lock_irqsave(&queue->irqlock, flags);
        ret = (queue->flags & UVC_QUEUE_PAUSED) != 0;
        queue->flags &= ~UVC_QUEUE_PAUSED;
        spin_unlock_irqrestore(&queue->irqlock, flags);
-       mutex_unlock(&queue->mutex);
 
+done:
+       mutex_unlock(&queue->mutex);
        return ret;
 }