Commit 4f1bdf0a authored by Maciej S. Szmigiero's avatar Maciej S. Szmigiero Committed by Mauro Carvalho Chehab

media: cx25840: fix a possible divide by zero in set_fmt callback

If set_fmt callback is called with format->width or format->height set to
zero and HACTIVE_CNT or VACTIVE_CNT bits (respectively) in chip are zero
we will divide by zero later in this callback when we try to calculate
HSC or VSC values.

Fix this by explicitly rejecting these values.
Signed-off-by: default avatarMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 7ff06130
...@@ -1395,7 +1395,8 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd, ...@@ -1395,7 +1395,8 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd,
* height. Without that margin the cx23885 fails in this * height. Without that margin the cx23885 fails in this
* check. * check.
*/ */
if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) || if ((fmt->width == 0) || (Vlines == 0) ||
(fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) ||
(Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) { (Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) {
v4l_err(client, "%dx%d is not a valid size!\n", v4l_err(client, "%dx%d is not a valid size!\n",
fmt->width, fmt->height); fmt->width, fmt->height);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment