Commit ecb7b018 authored by Peter Rosin's avatar Peter Rosin Committed by Mauro Carvalho Chehab

[media] m88ds3103: fix undefined division

s32tmp in the below code may be negative, and dev->mclk_khz is an
unsigned type.

	s32tmp = 0x10000 * (tuner_frequency - c->frequency);
	s32tmp = DIV_ROUND_CLOSEST(s32tmp, dev->mclk_khz);

This is undefined, as DIV_ROUND_CLOSEST is undefined for negative
dividends when the divisor is of unsigned type.

So, change mclk_khz to be signed (s32).
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 71c5daba
......@@ -46,7 +46,7 @@ struct m88ds3103_dev {
/* auto detect chip id to do different config */
u8 chip_id;
/* main mclk is calculated for M88RS6000 dynamically */
u32 mclk_khz;
s32 mclk_khz;
u64 post_bit_error;
u64 post_bit_count;
};
......
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