summaryrefslogtreecommitdiff
path: root/v4l2.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-05-22 10:20:35 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-05-22 10:20:35 +0300
commit73a03b3571e14233232494f301303ebba14957dc (patch)
treef4eb3c77b6f3a4feca962cf441b9194a1c96cb14 /v4l2.c
parent160f480a46cbd23873b59ea860b83d47dc98374d (diff)
v4l2: Fail v4l2_alloc_buffers() when buffers are already allocated
Allocating buffers allocates resources that must be explicitly freed. Calling v4l2_alloc_buffers() a second time without freeing the buffers in between causes memory leaks and must not be allowed. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'v4l2.c')
-rw-r--r--v4l2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/v4l2.c b/v4l2.c
index 3baf55b..8d5e847 100644
--- a/v4l2.c
+++ b/v4l2.c
@@ -510,6 +510,9 @@ int v4l2_alloc_buffers(struct v4l2_device *dev, enum v4l2_memory memtype,
unsigned int i;
int ret;
+ if (dev->nbufs != 0)
+ return -EBUSY;
+
/* Request the buffers from the driver. */
memset(&rb, 0, sizeof rb);
rb.count = nbufs;