[media] media: vb2: add a check for uninitialized buffer
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 12 Oct 2011 16:09:53 +0000 (13:09 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 8 Nov 2011 10:59:33 +0000 (08:59 -0200)
__buffer_in_use() might be called for empty/uninitialized buffer in the
following scenario: REQBUF(n, USER_PTR), QUERYBUF(). This patch fixes
kernel ops in such case.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Pawel Osciak <pawel@osciak.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf2-core.c

index 979e544388cbfbdea4efa2ea1c1bb321e1d37897..9bb92145ad5a311f0bdf4d0d5df95c0fd1b57fc7 100644 (file)
@@ -296,14 +296,14 @@ static bool __buffer_in_use(struct vb2_queue *q, struct vb2_buffer *vb)
 {
        unsigned int plane;
        for (plane = 0; plane < vb->num_planes; ++plane) {
+               void *mem_priv = vb->planes[plane].mem_priv;
                /*
                 * If num_users() has not been provided, call_memop
                 * will return 0, apparently nobody cares about this
                 * case anyway. If num_users() returns more than 1,
                 * we are not the only user of the plane's memory.
                 */
-               if (call_memop(q, plane, num_users,
-                               vb->planes[plane].mem_priv) > 1)
+               if (mem_priv && call_memop(q, plane, num_users, mem_priv) > 1)
                        return true;
        }
        return false;