Skip to content

Commit

Permalink
[media] videobuf2-dma-sg: fix possible memory leak
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Geyslan G. Bem authored and Mauro Carvalho Chehab committed Dec 10, 2013
1 parent a5e3d74 commit 64c832a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/media/v4l2-core/videobuf2-dma-sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -204,6 +204,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
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;
}
Expand Down

0 comments on commit 64c832a

Please sign in to comment.