From 36e49ffb978ef7284ae235b915a7bd6713aa20de Mon Sep 17 00:00:00 2001 From: Gustavo A. R. Silva Date: Mon, 29 Jan 2018 19:32:01 -0500 Subject: media: i2c: ov9650: fix potential integer overflow in __ov965x_set_frame_interval Cast fi->interval.numerator to u64 in order to avoid a potential integer overflow. This variable is being used in a context that expects an expression of type u64. Addresses-Coverity-ID: 1324146 ("Unintentional integer overflow") [Sakari Ailus: use do_div() to make this work on 32-bit systems] Signed-off-by: Gustavo A. R. Silva Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/ov9650.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c index bfd90162a297..5bea31cd41aa 100644 --- a/drivers/media/i2c/ov9650.c +++ b/drivers/media/i2c/ov9650.c @@ -1136,8 +1136,8 @@ static int __ov965x_set_frame_interval(struct ov965x *ov965x, if (fi->interval.denominator == 0) return -EINVAL; - req_int = (u64)(fi->interval.numerator * 10000) / - fi->interval.denominator; + req_int = (u64)fi->interval.numerator * 10000; + do_div(req_int, fi->interval.denominator); for (i = 0; i < ARRAY_SIZE(ov965x_intervals); i++) { const struct ov965x_interval *iv = &ov965x_intervals[i]; -- cgit v1.2.3