aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylwester Nawrocki <sylvester.nawrocki@gmail.com>2013-02-07 16:36:12 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:53:47 -0500
commit69b95a3a80b44ebb71bf153e79bcb8580e1d3de5 (patch)
treef253d9be9bc959805dbda0af47b48da90069bc37
parent6aa69f99b2ecc7f9b387fcf22d30e6601b58819f (diff)
[media] s3c-camif: Fail on insufficient number of allocated buffers
Ensure the driver gets always at least its minimum required number of buffers allocated by checking actual number of allocated buffers in vb2_reqbufs(). And free any partially allocated buffer queue with signaling an error to user space. Without this patch applications may wait forever to dequeue a filled buffer, because the hardware didn't even start after VIDIOC_STREAMON, VIDIOC_QBUF calls, due to insufficient number of empty buffers. Reported-by: Alexander Nestorov <alexandernst@gmail.com> Signed-off-by: Sylwester Nawrocki <sylvester.nawrocki@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/s3c-camif/camif-capture.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index e91f350929eb..70438a0f62ae 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -934,12 +934,19 @@ static int s3c_camif_reqbufs(struct file *file, void *priv,
934 vp->owner = NULL; 934 vp->owner = NULL;
935 935
936 ret = vb2_reqbufs(&vp->vb_queue, rb); 936 ret = vb2_reqbufs(&vp->vb_queue, rb);
937 if (!ret) { 937 if (ret < 0)
938 vp->reqbufs_count = rb->count; 938 return ret;
939 if (vp->owner == NULL && rb->count > 0) 939
940 vp->owner = priv; 940 if (rb->count && rb->count < CAMIF_REQ_BUFS_MIN) {
941 rb->count = 0;
942 vb2_reqbufs(&vp->vb_queue, rb);
943 ret = -ENOMEM;
941 } 944 }
942 945
946 vp->reqbufs_count = rb->count;
947 if (vp->owner == NULL && rb->count > 0)
948 vp->owner = priv;
949
943 return ret; 950 return ret;
944} 951}
945 952