diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2018-05-22 10:20:35 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2018-05-22 10:20:35 +0300 |
commit | 73a03b3571e14233232494f301303ebba14957dc (patch) | |
tree | f4eb3c77b6f3a4feca962cf441b9194a1c96cb14 /v4l2.c | |
parent | 160f480a46cbd23873b59ea860b83d47dc98374d (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.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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; |