[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1384981372-5579-1-git-send-email-geyslan@gmail.com>
Date: Wed, 20 Nov 2013 18:02:52 -0300
From: "Geyslan G. Bem" <geyslan@...il.com>
To: linux-kernel@...r.kernel.org
Cc: kernel-br@...glegroups.com, "Geyslan G. Bem" <geyslan@...il.com>,
Pawel Osciak <pawel@...iak.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
Mauro Carvalho Chehab <m.chehab@...sung.com>,
linux-media@...r.kernel.org (open list:VIDEOBUF2 FRAMEWORK)
Subject: [PATCH] videobuf2-dma-sg: fix possible memory leak
Fix the return when 'buf->pages' allocation error.
Signed-off-by: Geyslan G. Bem <geyslan@...il.com>
---
drivers/media/v4l2-core/videobuf2-dma-sg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 2f86054..0d3a8ff 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;
}
--
1.8.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists