]> git.baikalelectronics.ru Git - kernel.git/commit
i2c: altera: Fix potential integer overflow
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Tue, 11 Feb 2020 14:47:04 +0000 (08:47 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Mar 2020 15:43:45 +0000 (16:43 +0100)
commitb129bbd1827d80ea5639a60aafc286c525c06dff
treeb40a2b24c555820c9eb7971d059db14ed89038b9
parent6798ff2be81a008d468d129bf580ea9080eea0ac
i2c: altera: Fix potential integer overflow

commit d5942f9fc70af71b4f8cdc6438e7e93a41488fab upstream.

Factor out 100 from the equation and do 32-bit arithmetic (3 * clk_mhz / 10)
instead of 64-bit.

Notice that clk_mhz is MHz, so the multiplication will never wrap 32 bits
and there is no need for div_u64().

Addresses-Coverity: 1458369 ("Unintentional integer overflow")
Fixes: a239e2640e63 ("i2c: altera: Add Altera I2C Controller driver")
Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Thor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/i2c/busses/i2c-altera.c