[media] v4l2: vb2-dma-sg: fix memory leak
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Fri, 28 Jan 2011 12:42:51 +0000 (09:42 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 22 Mar 2011 07:54:27 +0000 (04:54 -0300)
This patch fixes two minor memory leaks in videobuf2-dma-sg module. They
might happen only in case some other operations (like memory allocation)
failed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf2-dma-sg.c

index 20b5c5dcc0ef3ccd5c57e47e7d424c18b2b46fd9..d5311ff3fab00c9a4d6db348c46028f581b3420f 100644 (file)
@@ -88,6 +88,7 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size)
 fail_pages_alloc:
        while (--i >= 0)
                __free_page(buf->pages[i]);
+       kfree(buf->pages);
 
 fail_pages_array_alloc:
        vfree(buf->sg_desc.sglist);
@@ -176,6 +177,7 @@ userptr_fail_get_user_pages:
               num_pages_from_user, buf->sg_desc.num_pages);
        while (--num_pages_from_user >= 0)
                put_page(buf->pages[num_pages_from_user]);
+       kfree(buf->pages);
 
 userptr_fail_pages_array_alloc:
        vfree(buf->sg_desc.sglist);