On 02/14/2014 11:41 AM, Hans Verkuil wrote: > From: Hans Verkuil <hans.verkuil@xxxxxxxxx> > > In __reqbufs() and __create_bufs() the q->num_buffers field was updated > with the number of newly allocated buffers, but right after that those are > freed again if some error had occurred before. Move the line updating > num_buffers to *after* that error check. > > Signed-off-by: Hans Verkuil <hans.verkuil@xxxxxxxxx> NACK: this is actually correct behavior since __vb2_queue_free() subtracts 'allocated_buffers' from q->num_buffers. A comment mentioning this might be useful, though. Regards, Hans > --- > drivers/media/v4l2-core/videobuf2-core.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c > index ad3db83..96c5ac6 100644 > --- a/drivers/media/v4l2-core/videobuf2-core.c > +++ b/drivers/media/v4l2-core/videobuf2-core.c > @@ -848,13 +848,13 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) > */ > } > > - q->num_buffers = allocated_buffers; > - > if (ret < 0) { > __vb2_queue_free(q, allocated_buffers); > return ret; > } > > + q->num_buffers = allocated_buffers; > + > /* > * Return the number of successfully allocated buffers > * to the userspace. > @@ -957,13 +957,13 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create > */ > } > > - q->num_buffers += allocated_buffers; > - > if (ret < 0) { > __vb2_queue_free(q, allocated_buffers); > return -ENOMEM; > } > > + q->num_buffers += allocated_buffers; > + > /* > * Return the number of successfully allocated buffers > * to the userspace. > -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html