diff options
author | Dr. David Alan Gilbert <linux@treblig.org> | 2010-10-24 12:33:09 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-25 16:53:44 -0400 |
commit | 910f5f05f99c1ffbb484c4e6eb2a460e7a08e2d7 (patch) | |
tree | 51bafcd6627b43233ce0896ecae489b8a19ee00a /drivers/media | |
parent | 52fae5eead706cb8d604ee634162f6694d75ccad (diff) |
[media] Guard a divide in v4l1 compat layer
Hi,
I managed to trigger a divide by 0 in the v4l compat code
with the mem2mem test module; I suspect perhaps it shouldn't
have been returning a 0 pixel wide picture, but either way it seems
right to guard this divide by 0 in the compatibility layer.
Tested on 2.6.36 (ubuntu build, but the code in this is the same as upstream),
but ***not tested with a real video device***.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
cc: stable.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/v4l1-compat.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index 0c2105ca611e..d4ac751036a2 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c | |||
@@ -645,9 +645,16 @@ static noinline long v4l1_compat_get_picture( | |||
645 | goto done; | 645 | goto done; |
646 | } | 646 | } |
647 | 647 | ||
648 | pict->depth = ((fmt->fmt.pix.bytesperline << 3) | 648 | if (fmt->fmt.pix.width) |
649 | + (fmt->fmt.pix.width - 1)) | 649 | { |
650 | / fmt->fmt.pix.width; | 650 | pict->depth = ((fmt->fmt.pix.bytesperline << 3) |
651 | + (fmt->fmt.pix.width - 1)) | ||
652 | / fmt->fmt.pix.width; | ||
653 | } else { | ||
654 | err = -EINVAL; | ||
655 | goto done; | ||
656 | } | ||
657 | |||
651 | pict->palette = pixelformat_to_palette( | 658 | pict->palette = pixelformat_to_palette( |
652 | fmt->fmt.pix.pixelformat); | 659 | fmt->fmt.pix.pixelformat); |
653 | done: | 660 | done: |