Josh Boyer 9b66eee
From 3771973542a4807b251352253ed22c50e688e573 Mon Sep 17 00:00:00 2001
Josh Boyer 9b66eee
From: Jayakrishnan Memana <jayakrishnan.memana@maxim-ic.com>
Josh Boyer 9b66eee
Date: Sun, 15 Jul 2012 15:54:03 +0200
Josh Boyer 9b66eee
Subject: [PATCH] uvcvideo: Reset the bytesused field when recycling an erroneous buffer
Josh Boyer 9b66eee
Josh Boyer 9b66eee
Buffers marked as erroneous are recycled immediately by the driver if
Josh Boyer 9b66eee
the nodrop module parameter isn't set. The buffer payload size is reset
Josh Boyer 9b66eee
to 0, but the buffer bytesused field isn't. This results in the buffer
Josh Boyer 9b66eee
being immediately considered as complete, leading to an infinite loop in
Josh Boyer 9b66eee
interrupt context.
Josh Boyer 9b66eee
Josh Boyer 9b66eee
Fix the problem by resetting the bytesused field when recycling the
Josh Boyer 9b66eee
buffer.
Josh Boyer 9b66eee
Josh Boyer 9b66eee
Cc: <stable@vger.kernel.org>
Josh Boyer 9b66eee
Signed-off-by: Jayakrishnan Memana <jayakrishnan.memana@maxim-ic.com>
Josh Boyer 9b66eee
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Josh Boyer 9b66eee
---
Josh Boyer 9b66eee
 drivers/media/video/uvc/uvc_queue.c |    1 +
Josh Boyer 9b66eee
 1 files changed, 1 insertions(+), 0 deletions(-)
Josh Boyer 9b66eee
Josh Boyer 9b66eee
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c
Josh Boyer 9b66eee
index 9288fbd..5577381 100644
Josh Boyer 9b66eee
--- a/drivers/media/video/uvc/uvc_queue.c
Josh Boyer 9b66eee
+++ b/drivers/media/video/uvc/uvc_queue.c
Josh Boyer 9b66eee
@@ -338,6 +338,7 @@ struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue,
Josh Boyer 9b66eee
 	if ((queue->flags & UVC_QUEUE_DROP_CORRUPTED) && buf->error) {
Josh Boyer 9b66eee
 		buf->error = 0;
Josh Boyer 9b66eee
 		buf->state = UVC_BUF_STATE_QUEUED;
Josh Boyer 9b66eee
+		buf->bytesused = 0;
Josh Boyer 9b66eee
 		vb2_set_plane_payload(&buf->buf, 0, 0);
Josh Boyer 9b66eee
 		return buf;
Josh Boyer 9b66eee
 	}
Josh Boyer 9b66eee
-- 
Josh Boyer 9b66eee
1.7.2.5
Josh Boyer 9b66eee