diff options
author | Brandon Philips <brandon@ifup.org> | 2008-04-02 11:10:59 -0700 |
---|---|---|
committer | Brandon Philips <brandon@ifup.org> | 2008-04-02 11:10:59 -0700 |
commit | 16db1a41499bb1ebb8e6fef05a638a9dfc971892 (patch) | |
tree | b62555d25b7eb0a6d2ed1b5be4e9f078f6792b79 | |
parent | e385e87fd1da4f48a906ba73fb5dc17f39de479c (diff) | |
download | mediapointer-dvb-s2-16db1a41499bb1ebb8e6fef05a638a9dfc971892.tar.gz mediapointer-dvb-s2-16db1a41499bb1ebb8e6fef05a638a9dfc971892.tar.bz2 |
videobuf-dma-sg.c: Avoid NULL dereference and add comment about backwards compatibility
Signed-off-by: Brandon Philips <bphilips@suse.de>
---
linux/drivers/media/video/videobuf-dma-sg.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
-rw-r--r-- | linux/drivers/media/video/videobuf-dma-sg.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/linux/drivers/media/video/videobuf-dma-sg.c b/linux/drivers/media/video/videobuf-dma-sg.c index eeab4a570..06a219e0d 100644 --- a/linux/drivers/media/video/videobuf-dma-sg.c +++ b/linux/drivers/media/video/videobuf-dma-sg.c @@ -592,6 +592,14 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, goto done; } + /* This function maintains backwards compatibility with V4L1 and will + * map more than one buffer if the vma length is equal to the combined + * size of multiple buffers than it will map them together. See + * VIDIOCGMBUF in the v4l spec + * + * TODO: Allow drivers to specify if they support this mode + */ + /* look for first buffer to map */ for (first = 0; first < VIDEO_MAX_FRAME; first++) { if (NULL == q->bufs[first]) @@ -636,10 +644,16 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); if (NULL == map) goto done; - for (size = 0, i = first; i <= last; size += q->bufs[i++]->bsize) { + + size = 0; + for (i = first; i <= last; i++) { + if (NULL == q->bufs[i]) + continue; q->bufs[i]->map = map; q->bufs[i]->baddr = vma->vm_start + size; + size += q->bufs[i]->bsize; } + map->count = 1; map->start = vma->vm_start; map->end = vma->vm_end; |