[Skiboot] [PATCH] hdata/i2c: avoid possible int32_t overflow

Stewart Smith stewart at linux.vnet.ibm.com
Wed May 10 15:00:55 AEST 2017


We're safe up until engine number 524288.

Found by static analysis

Fixes: ae4e50eb35695
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 hdata/i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hdata/i2c.c b/hdata/i2c.c
index 24e92573d6e5..f5c5bafe758b 100644
--- a/hdata/i2c.c
+++ b/hdata/i2c.c
@@ -29,7 +29,7 @@ struct i2c_dev {
 
 static struct dt_node *get_i2cm_node(struct dt_node *xscom, int engine)
 {
-	uint64_t xscom_base = P9_I2CM_XSCOM_BASE + P9_I2CM_XSCOM_SIZE * engine;
+	uint64_t xscom_base = P9_I2CM_XSCOM_BASE + P9_I2CM_XSCOM_SIZE * (uint64_t)engine;
 	struct dt_node *i2cm;
 	uint64_t freq, clock;
 
-- 
2.9.3



More information about the Skiboot mailing list