Skip to contentSkip to conversation

media: tda18250: fix possible integer overflow

PATCH New Ilya Krutskih 1 participant 1 message Jul 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: tda18250: fix possible integer overflow

Integer overflow may occur, when variable exp equals to zero. Result of shift 1 << (exp - 1) may then leads to undefined behavior.

Fixes 148abd3b5b14 ("media: tda18250: support for new silicon tuner")
---
 drivers/media/tuners/tda18250.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/tuners/tda18250.c +2 -2
index 8a5781b966ee..d1d97da05215 100644
@@ -440,8 +440,8 @@ static int tda18250_pll_calc(struct dvb_frontend *fe, u8 *rdiv,
 		goto err;
 
 	exp = (uval & 0x70) >> 4;
-	if (exp > 5)
-		exp = 0;
+	if (exp == 0 || exp > 5)
+		exp = 1;
 	lopd = 1 << (exp - 1);
 	scale = uval & 0x0f;
 	fvco = lopd * scale * ((c->frequency / 1000) + dev->if_frequency);
Signature · 1 line
2.43.0