Skip to content

Commit

Permalink
V4L/DVB: v4l: videobuf: prevent passing a NULL to dma_free_coherent()
Browse files Browse the repository at this point in the history
When a driver that uses videobuf-dma-contig is used with the USERPTR
memory access method a kernel oops might happen: a NULL address may be
passed to dma_free_coherent(). This happens when an application calls
REQBUFS and then exits without queuing any buffers. This patch fixes
that bug.

Signed-off-by: Pawel Osciak <p.osciak@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Pawel Osciak authored and Mauro Carvalho Chehab committed Sep 30, 2010
1 parent a08c7c6 commit b2b476f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/media/video/videobuf-dma-contig.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ void videobuf_dma_contig_free(struct videobuf_queue *q,
}

/* read() method */
dma_free_coherent(q->dev, mem->size, mem->vaddr, mem->dma_handle);
mem->vaddr = NULL;
if (mem->vaddr) {
dma_free_coherent(q->dev, mem->size, mem->vaddr, mem->dma_handle);
mem->vaddr = NULL;
}
}
EXPORT_SYMBOL_GPL(videobuf_dma_contig_free);

Expand Down

0 comments on commit b2b476f

Please sign in to comment.