Skip to content

Commit 554df75

Browse files
Ma KeHans Verkuil
authored andcommitted
media: videobuf2: Fix IS_ERR checking in vb2_dc_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]>
1 parent 2a76e76 commit 554df75

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/media/common/videobuf2/videobuf2-dma-contig.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,14 @@ static void vb2_dc_put_userptr(void *buf_priv)
542542
*/
543543
dma_unmap_sgtable(buf->dev, sgt, buf->dma_dir,
544544
DMA_ATTR_SKIP_CPU_SYNC);
545-
pages = frame_vector_pages(buf->vec);
546-
/* sgt should exist only if vector contains pages... */
547-
BUG_ON(IS_ERR(pages));
548545
if (buf->dma_dir == DMA_FROM_DEVICE ||
549-
buf->dma_dir == DMA_BIDIRECTIONAL)
550-
for (i = 0; i < frame_vector_count(buf->vec); i++)
551-
set_page_dirty_lock(pages[i]);
546+
buf->dma_dir == DMA_BIDIRECTIONAL) {
547+
pages = frame_vector_pages(buf->vec);
548+
/* sgt should exist only if vector contains pages... */
549+
if (!WARN_ON_ONCE(IS_ERR(pages)))
550+
for (i = 0; i < frame_vector_count(buf->vec); i++)
551+
set_page_dirty_lock(pages[i]);
552+
}
552553
sg_free_table(sgt);
553554
kfree(sgt);
554555
} else {

0 commit comments

Comments
 (0)