[media] vb2: call buf_finish after the state check
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 28 Feb 2014 16:30:48 +0000 (13:30 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 11 Mar 2014 09:56:44 +0000 (06:56 -0300)
Don't call buf_finish unless we know that the buffer is in a valid state.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/v4l2-core/videobuf2-core.c

index d853cd47c86a265c40af20d5cb78a97a20ca2560..f9059bb73840acb8ebed02e9099ce445fc932d3d 100644 (file)
@@ -1929,8 +1929,6 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n
        if (ret < 0)
                return ret;
 
-       call_vb_qop(vb, buf_finish, vb);
-
        switch (vb->state) {
        case VB2_BUF_STATE_DONE:
                dprintk(3, "dqbuf: Returning done buffer\n");
@@ -1943,6 +1941,8 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n
                return -EINVAL;
        }
 
+       call_vb_qop(vb, buf_finish, vb);
+
        /* Fill buffer information for the userspace */
        __fill_v4l2_buffer(vb, b);
        /* Remove from videobuf queue */