Commit 4d831787 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (13107): tda18271: fix overflow in FM radio frequency calculation

Multiplication by 62500 causes an overflow in the 32 bit freq variable,
which is later divided by 1000 when using FM radio.

This patch prevents the overflow by scaling the frequency value correctly
upfront.  Thanks to Henk Vergonet for spotting the problem and providing
a preliminary patch, which this changeset was based upon.

Cc: Henk Vergonet <Henk.Vergonet@gmail.com>
Signed-off-by: default avatarMichael Krufky <mkrufky@kernellabs.com>
CC: stable@kernel.org
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7646b9de
...@@ -1000,12 +1000,12 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe, ...@@ -1000,12 +1000,12 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
struct tda18271_std_map_item *map; struct tda18271_std_map_item *map;
char *mode; char *mode;
int ret; int ret;
u32 freq = params->frequency * 62500; u32 freq = params->frequency * 125 *
((params->mode == V4L2_TUNER_RADIO) ? 1 : 1000) / 2;
priv->mode = TDA18271_ANALOG; priv->mode = TDA18271_ANALOG;
if (params->mode == V4L2_TUNER_RADIO) { if (params->mode == V4L2_TUNER_RADIO) {
freq = freq / 1000;
map = &std_map->fm_radio; map = &std_map->fm_radio;
mode = "fm"; mode = "fm";
} else if (params->std & V4L2_STD_MN) { } else if (params->std & V4L2_STD_MN) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment