Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64c832a4 authored by Geyslan G. Bem's avatar Geyslan G. Bem Committed by Mauro Carvalho Chehab
Browse files

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



Fix the return when 'buf->pages' allocation error.

Signed-off-by: default avatarGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
parent a5e3d743
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
}