Skip to content

Commit

Permalink
[media] Guard a divide in v4l1 compat layer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dr. David Alan Gilbert authored and Mauro Carvalho Chehab committed Oct 25, 2010
1 parent 52fae5e commit 910f5f0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/media/video/v4l1-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,9 +645,16 @@ static noinline long v4l1_compat_get_picture(
goto done;
}

pict->depth = ((fmt->fmt.pix.bytesperline << 3)
+ (fmt->fmt.pix.width - 1))
/ fmt->fmt.pix.width;
if (fmt->fmt.pix.width)
{
pict->depth = ((fmt->fmt.pix.bytesperline << 3)
+ (fmt->fmt.pix.width - 1))
/ fmt->fmt.pix.width;
} else {
err = -EINVAL;
goto done;
}

pict->palette = pixelformat_to_palette(
fmt->fmt.pix.pixelformat);
done:
Expand Down

0 comments on commit 910f5f0

Please sign in to comment.