diff options
author | Brandon Philips <brandon@ifup.org> | 2008-04-02 17:10:59 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:07:57 -0400 |
commit | ce54093cefd64c1a2cb6b8c5ed1d68d2bd7a34ab (patch) | |
tree | 886b3eaf7a05731618b95e8f24e6c33ebe8edc3e /drivers/media/video | |
parent | 137d1cb19d9da163ce6cb57a6fa1e6a3468af6a4 (diff) |
V4L/DVB (7494): videobuf-dma-sg.c: Avoid NULL dereference and add comment about backwards compatibility
Signed-off-by: Brandon Philips <bphilips@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/videobuf-dma-sg.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 717783fa8b3e..e6ce99ff7fd1 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
@@ -546,6 +546,14 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
546 | goto done; | 546 | goto done; |
547 | } | 547 | } |
548 | 548 | ||
549 | /* This function maintains backwards compatibility with V4L1 and will | ||
550 | * map more than one buffer if the vma length is equal to the combined | ||
551 | * size of multiple buffers than it will map them together. See | ||
552 | * VIDIOCGMBUF in the v4l spec | ||
553 | * | ||
554 | * TODO: Allow drivers to specify if they support this mode | ||
555 | */ | ||
556 | |||
549 | /* look for first buffer to map */ | 557 | /* look for first buffer to map */ |
550 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { | 558 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { |
551 | if (NULL == q->bufs[first]) | 559 | if (NULL == q->bufs[first]) |
@@ -590,10 +598,16 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
590 | map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); | 598 | map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); |
591 | if (NULL == map) | 599 | if (NULL == map) |
592 | goto done; | 600 | goto done; |
593 | for (size = 0, i = first; i <= last; size += q->bufs[i++]->bsize) { | 601 | |
602 | size = 0; | ||
603 | for (i = first; i <= last; i++) { | ||
604 | if (NULL == q->bufs[i]) | ||
605 | continue; | ||
594 | q->bufs[i]->map = map; | 606 | q->bufs[i]->map = map; |
595 | q->bufs[i]->baddr = vma->vm_start + size; | 607 | q->bufs[i]->baddr = vma->vm_start + size; |
608 | size += q->bufs[i]->bsize; | ||
596 | } | 609 | } |
610 | |||
597 | map->count = 1; | 611 | map->count = 1; |
598 | map->start = vma->vm_start; | 612 | map->start = vma->vm_start; |
599 | map->end = vma->vm_end; | 613 | map->end = vma->vm_end; |