]> git.proxmox.com Git - mirror_ubuntu-focal-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)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 6 Mar 2020 11:38:23 +0000 (12:38 +0100)
commitfa115486bfbfc5a32e4cec060fdcd94d2fa9cccd
tree8cec97421e586041fd891d9e0091d39aa3999135
parentdec94797304d50882572ef64df1a7f39235add58
i2c: altera: Fix potential integer overflow

BugLink: https://bugs.launchpad.net/bugs/1866333
commit 54498e8070e19e74498a72c7331348143e7e1f8c 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: 0560ad576268 ("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>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/i2c/busses/i2c-altera.c