Skip to content

Commit feec1b2

Browse files
Ma KeHans Verkuil
authored andcommitted
media: videobuf2: Fix IS_ERR checking in vb2_vmalloc_put_userptr()
In order to avoid error pointers from frame_vector_pages(), we could use IS_ERR() to check the return value to fix this. This checking operation could make sure that vector contains pages. Signed-off-by: Ma Ke <[email protected]> Acked-by: Tomasz Figa <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> [hverkuil: add space between ){] Signed-off-by: Hans Verkuil <[email protected]>
1 parent be521bf commit feec1b2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/media/common/videobuf2/videobuf2-vmalloc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,15 @@ static void vb2_vmalloc_put_userptr(void *buf_priv)
133133

134134
if (!buf->vec->is_pfns) {
135135
n_pages = frame_vector_count(buf->vec);
136-
pages = frame_vector_pages(buf->vec);
137136
if (vaddr)
138137
vm_unmap_ram((void *)vaddr, n_pages);
139138
if (buf->dma_dir == DMA_FROM_DEVICE ||
140-
buf->dma_dir == DMA_BIDIRECTIONAL)
141-
for (i = 0; i < n_pages; i++)
142-
set_page_dirty_lock(pages[i]);
139+
buf->dma_dir == DMA_BIDIRECTIONAL) {
140+
pages = frame_vector_pages(buf->vec);
141+
if (!WARN_ON_ONCE(IS_ERR(pages)))
142+
for (i = 0; i < n_pages; i++)
143+
set_page_dirty_lock(pages[i]);
144+
}
143145
} else {
144146
iounmap((__force void __iomem *)buf->vaddr);
145147
}

0 commit comments

Comments
 (0)