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 <gustavo@embeddedor.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Gustavo A. R. Silva 2018-01-29 19:32:01 -05:00 коммит произвёл Mauro Carvalho Chehab
Родитель b1f5d0ae93
Коммит 36e49ffb97
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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];