From: Marek Szyprowski Date: Tue, 28 Jun 2011 11:29:02 +0000 (-0300) Subject: [media] media: vb2: fix allocation failure check X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=66072d4fa7cb644f1f064e290f8fddfbd8ccd478;p=~shefty%2Frdma-dev.git [media] media: vb2: fix allocation failure check __vb2_queue_alloc function returns the number of successfully allocated buffers. There is no point in checking if the returned value is negative. If this function returns 0, videobuf2 should just return -ENOMEM to userspace, because no driver can work without memory buffers. Reported-by: Jonathan Corbet Signed-off-by: Marek Szyprowski Signed-off-by: Kyungmin Park CC: Pawel Osciak Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 84f03b25aed..3015e600094 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -532,9 +532,9 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) /* Finally, allocate buffers and video memory */ ret = __vb2_queue_alloc(q, req->memory, num_buffers, num_planes, plane_sizes); - if (ret < 0) { - dprintk(1, "Memory allocation failed with error: %d\n", ret); - return ret; + if (ret == 0) { + dprintk(1, "Memory allocation failed\n"); + return -ENOMEM; } /*