Skip to content

Commit 23d3090

Browse files
Dan Carpentermchehab
authored andcommitted
[media] vmalloc_sg: off by one in error handling
The "i--" needs to happen at the start of the loop or it will try to release something bogus (probably it will crash) and it won't release the first ->vaddr_page[]. Fixes: 7b4eeed ('[media] vmalloc_sg: make sure all pages in vmalloc area are really DMA-ready') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
1 parent 5b6aa19 commit 23d3090

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/media/v4l2-core/videobuf-dma-sg.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,11 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
253253
return 0;
254254
out_free_pages:
255255
while (i > 0) {
256-
void *addr = page_address(dma->vaddr_pages[i]);
257-
dma_free_coherent(dma->dev, PAGE_SIZE, addr, dma->dma_addr[i]);
256+
void *addr;
257+
258258
i--;
259+
addr = page_address(dma->vaddr_pages[i]);
260+
dma_free_coherent(dma->dev, PAGE_SIZE, addr, dma->dma_addr[i]);
259261
}
260262
kfree(dma->dma_addr);
261263
dma->dma_addr = NULL;

0 commit comments

Comments
 (0)