[PATCH 27/91] uvcvideo: Remove buffers from the queues when freeing

From: Willy Tarreau
Date: Sun Feb 05 2012 - 17:43:39 EST


2.6.27-longterm review patch. If anyone has any objections, please let us know.

------------------

commit 8ca2c80b170c47eeb55f0c2a0f2b8edf85f35d49 upstream.

When freeing memory for the video buffers also remove them from the
irq & main queues.

This fixes an oops when doing the following:

open ("/dev/video", ..)
VIDIOC_REQBUFS
VIDIOC_QBUF
VIDIOC_REQBUFS
close ()

As the second VIDIOC_REQBUFS will cause the list entries of the buffers
to be cleared while they still hang around on the main and irc queues

Signed-off-by: Sjoerd Simons <sjoerd.simons@xxxxxxxxxxxxxxx>
Acked-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
Signed-off-by: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
drivers/media/video/uvc/uvc_queue.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

Index: longterm-2.6.27/drivers/media/video/uvc/uvc_queue.c
===================================================================
--- longterm-2.6.27.orig/drivers/media/video/uvc/uvc_queue.c 2012-02-05 22:34:34.215915503 +0100
+++ longterm-2.6.27/drivers/media/video/uvc/uvc_queue.c 2012-02-05 22:34:38.711914474 +0100
@@ -165,6 +165,8 @@
}

if (queue->count) {
+ uvc_queue_cancel(queue, 0);
+ INIT_LIST_HEAD(&queue->mainqueue);
vfree(queue->mem);
queue->count = 0;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/