]> git.karo-electronics.de Git - karo-tx-linux.git/commit
ASoC: fsl_spdif: Fix integer overflow when calculating divisors
authorAnssi Hannula <anssi.hannula@iki.fi>
Mon, 9 Jun 2014 16:16:43 +0000 (19:16 +0300)
committerNitin Garg <nitin.garg@freescale.com>
Fri, 16 Jan 2015 03:16:53 +0000 (21:16 -0600)
commit5dcd0117f8ee67d454119efd2ab5190e86ba05c0
treec49303bbfe12b77baeb16462632970b64c40f80b
parent3b9c09f76b6d38d8084b70fbf976c312158d1132
ASoC: fsl_spdif: Fix integer overflow when calculating divisors

The calculation code does
u64 = (u32 - u32) * 100000;

The 64 bits are of no help here as the type is casted only after the
multiplication, and therefore the result may overflow, possibly causing
inoptimal or wrong clock setup in an unfortunate case (the maximum
result value of the first substraction is currently 47999).

Fix the code to cast before multiplication.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Acked-by: Nicolin Chen <Guangyu.Chen@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit c89c7e94bb7d89b39471c79034e3ba1b25d817f5)
sound/soc/fsl/fsl_spdif.c