[media] videobuf2-core: call __setup_offsets only for mmap memory type
authorPhilipp Zabel <p.zabel@pengutronix.de>
Thu, 19 Sep 2013 07:37:29 +0000 (04:37 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Thu, 17 Oct 2013 13:53:21 +0000 (10:53 -0300)
__setup_offsets fills the v4l2_planes' mem_offset fields, which is only valid
for V4L2_MEMORY_MMAP type buffers. For V4L2_MEMORY_DMABUF and _USERPTR buffers,
this incorrectly overwrites the fd and userptr fields.

Reported-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Pawel Osciak <pawel@osciak.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/videobuf2-core.c

index fc8af507beac27cb0fb271754325d58017c17251..91412d463ba0e1eba3a311514f42dbe086a587a6 100644 (file)
@@ -241,7 +241,8 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
                q->bufs[q->num_buffers + buffer] = vb;
        }
 
-       __setup_offsets(q, buffer);
+       if (memory == V4L2_MEMORY_MMAP)
+               __setup_offsets(q, buffer);
 
        dprintk(1, "Allocated %d buffers, %d plane(s) each\n",
                        buffer, num_planes);