summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>2017-10-10 17:35:37 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-11 13:04:33 -0500
commit4f1bdf0a75a4d16149c470800d8c4bf3da13e92d (patch)
tree409f8bbb0ec0b41668de90049a4da0e81799008e /drivers/media/i2c
parent7ff061303382ed4151ff6932a9f356f6aac0bc4a (diff)
downloadlinux-4f1bdf0a75a4d16149c470800d8c4bf3da13e92d.tar.gz
linux-4f1bdf0a75a4d16149c470800d8c4bf3da13e92d.tar.bz2
linux-4f1bdf0a75a4d16149c470800d8c4bf3da13e92d.zip
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: Maciej S. Szmigiero <mail@maciej.szmigiero.name> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/cx25840/cx25840-core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/i2c/cx25840/cx25840-core.c b/drivers/media/i2c/cx25840/cx25840-core.c
index ec0e91369853..940c8b171249 100644
--- a/drivers/media/i2c/cx25840/cx25840-core.c
+++ b/drivers/media/i2c/cx25840/cx25840-core.c
@@ -1395,8 +1395,9 @@ static int cx25840_set_fmt(struct v4l2_subdev *sd,
* height. Without that margin the cx23885 fails in this
* check.
*/
- if ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) ||
- (Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) {
+ if ((fmt->width == 0) || (Vlines == 0) ||
+ (fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) ||
+ (Vlines * 8 < Vsrc) || (Vsrc + 1 < Vlines)) {
v4l_err(client, "%dx%d is not a valid size!\n",
fmt->width, fmt->height);
return -ERANGE;