diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-07-11 22:09:29 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-07-11 22:19:59 +0200 |
commit | 9b242594bfe0256419d5cf2b0701d2997beccc8b (patch) | |
tree | c10fa57665068d8eff35276071187bbfd55d621e /yavta.c | |
parent | a43ed0ea2776a22536ae1bf8359b0a12bbcbfdbd (diff) |
Free userspace buffers when freeing video buffers
Memory allocated with posix_memalign() must be freed with free().
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'yavta.c')
-rw-r--r-- | yavta.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -425,14 +425,25 @@ static int video_free_buffers(struct device *dev) if (dev->nbufs == 0) return 0; - if (dev->memtype == V4L2_MEMORY_MMAP) { - for (i = 0; i < dev->nbufs; ++i) { + for (i = 0; i < dev->nbufs; ++i) { + switch (dev->memtype) { + case V4L2_MEMORY_MMAP: ret = munmap(dev->buffers[i].mem, dev->buffers[i].size); if (ret < 0) { printf("Unable to unmap buffer %u (%d)\n", i, errno); return ret; } + break; + + case V4L2_MEMORY_USERPTR: + free(dev->buffers[i].mem); + break; + + default: + break; } + + dev->buffers[i].mem = NULL; } memset(&rb, 0, sizeof rb); |