Skip to content

Commit 438d308

Browse files
committed
media: ar0521: don't overflow when checking PLL values
The PLL checks are comparing 64 bit integers with 32 bit ones, as reported by Coverity. Depending on the values of the variables, this may underflow. Fix it ensuring that both sides of the expression are u64. Fixes: 852b50a ("media: On Semi AR0521 sensor driver") Cc: stable@vger.kernel.org Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
1 parent 14a2276 commit 438d308

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/media/i2c/ar0521.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ static u32 calc_pll(struct ar0521_dev *sensor, u32 freq, u16 *pre_ptr, u16 *mult
255255
continue; /* Minimum value */
256256
if (new_mult > 254)
257257
break; /* Maximum, larger pre won't work either */
258-
if (sensor->extclk_freq * (u64)new_mult < AR0521_PLL_MIN *
258+
if (sensor->extclk_freq * (u64)new_mult < (u64)AR0521_PLL_MIN *
259259
new_pre)
260260
continue;
261-
if (sensor->extclk_freq * (u64)new_mult > AR0521_PLL_MAX *
261+
if (sensor->extclk_freq * (u64)new_mult > (u64)AR0521_PLL_MAX *
262262
new_pre)
263263
break; /* Larger pre won't work either */
264264
new_pll = div64_round_up(sensor->extclk_freq * (u64)new_mult,

0 commit comments

Comments
 (0)