media: ar0521: don't overflow when checking PLL values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>

commit 438d3085ba5b8b5bfa5290faa594e577f6ac9aa7 upstream.

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: 852b50aeed15 ("media: On Semi AR0521 sensor driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
Acked-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/media/i2c/ar0521.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/media/i2c/ar0521.c
+++ b/drivers/media/i2c/ar0521.c
@@ -223,10 +223,10 @@ static u32 calc_pll(struct ar0521_dev *s
 			continue; /* Minimum value */
 		if (new_mult > 254)
 			break; /* Maximum, larger pre won't work either */
-		if (sensor->extclk_freq * (u64)new_mult < AR0521_PLL_MIN *
+		if (sensor->extclk_freq * (u64)new_mult < (u64)AR0521_PLL_MIN *
 		    new_pre)
 			continue;
-		if (sensor->extclk_freq * (u64)new_mult > AR0521_PLL_MAX *
+		if (sensor->extclk_freq * (u64)new_mult > (u64)AR0521_PLL_MAX *
 		    new_pre)
 			break; /* Larger pre won't work either */
 		new_pll = div64_round_up(sensor->extclk_freq * (u64)new_mult,


Patches currently in stable-queue which might be from mchehab+huawei@xxxxxxxxxx are

queue-6.1/media-dvb_frontend-don-t-play-tricks-with-underflow-.patch
queue-6.1/media-cx24116-prevent-overflows-on-snr-calculus.patch
queue-6.1/media-adv7604-prevent-underflow-condition-when-repor.patch
queue-6.1/media-pulse8-cec-fix-data-timestamp-at-pulse8_setup.patch
queue-6.1/media-v4l2-ctrls-api-fix-error-handling-for-v4l2_g_ctrl.patch
queue-6.1/media-dvbdev-prevent-the-risk-of-out-of-memory-acces.patch
queue-6.1/media-v4l2-tpg-prevent-the-risk-of-a-division-by-zero.patch
queue-6.1/media-ar0521-don-t-overflow-when-checking-pll-values.patch
queue-6.1/media-s5p-jpeg-prevent-buffer-overflows.patch
queue-6.1/media-stb0899_algo-initialize-cfr-before-using-it.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux