]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
media: ts2020: avoid integer overflows on 32 bit machines
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 10 Jan 2018 12:20:39 +0000 (07:20 -0500)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 29 Jan 2018 12:46:46 +0000 (07:46 -0500)
Before this patch, when compiled for arm32, the signal strength
were reported as:

Lock   (0x1f) Signal= 4294908.66dBm C/N= 12.79dB

Because of a 32 bit integer overflow. After it, it is properly
reported as:

Lock   (0x1f) Signal= -58.64dBm C/N= 12.79dB

Cc: stable@vger.kernel.org
Fixes: 0f91c9d6bab9 ("[media] TS2020: Calculate tuner gain correctly")
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/dvb-frontends/ts2020.c

index 07f1726a57743adbbcbb052fd2d4ab757a07d91f..c55882a8da06c941ec7432c18b2f706334441a5d 100644 (file)
@@ -368,7 +368,7 @@ static int ts2020_read_tuner_gain(struct dvb_frontend *fe, unsigned v_agc,
                gain2 = clamp_t(long, gain2, 0, 13);
                v_agc = clamp_t(long, v_agc, 400, 1100);
 
-               *_gain = -(gain1 * 2330 +
+               *_gain = -((__s64)gain1 * 2330 +
                           gain2 * 3500 +
                           v_agc * 24 / 10 * 10 +
                           10000);
@@ -386,7 +386,7 @@ static int ts2020_read_tuner_gain(struct dvb_frontend *fe, unsigned v_agc,
                gain3 = clamp_t(long, gain3, 0, 6);
                v_agc = clamp_t(long, v_agc, 600, 1600);
 
-               *_gain = -(gain1 * 2650 +
+               *_gain = -((__s64)gain1 * 2650 +
                           gain2 * 3380 +
                           gain3 * 2850 +
                           v_agc * 176 / 100 * 10 -