summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeyslan G. Bem <geyslan@gmail.com>2013-11-20 18:02:52 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-10 05:40:57 -0200
commit64c832a4f79542809d6c10b8ec6225ff8b76092e (patch)
treee3ab4af41bdba5a3e3c65f1a1ea90124257a1f63
parenta5e3d743cb6ed2d73546eaf070138202c0c64a6f (diff)
[media] videobuf2-dma-sg: fix possible memory leak
Fix the return when 'buf->pages' allocation error. Signed-off-by: Geyslan G. Bem <geyslan@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-sg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 2f860543912c..0d3a8ffe47a3 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -178,7 +178,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
buf->pages = kzalloc(buf->num_pages * sizeof(struct page *),
GFP_KERNEL);
if (!buf->pages)
- return NULL;
+ goto userptr_fail_alloc_pages;
num_pages_from_user = get_user_pages(current, current->mm,
vaddr & PAGE_MASK,
@@ -204,6 +204,7 @@ userptr_fail_get_user_pages:
while (--num_pages_from_user >= 0)
put_page(buf->pages[num_pages_from_user]);
kfree(buf->pages);
+userptr_fail_alloc_pages:
kfree(buf);
return NULL;
}