提交 64c832a4 编写于 作者: G Geyslan G. Bem 提交者: Mauro Carvalho Chehab

[media] videobuf2-dma-sg: fix possible memory leak

Fix the return when 'buf->pages' allocation error.
Signed-off-by: NGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
上级 a5e3d743
......@@ -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 @@ 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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册