[U-Boot] [PATCH 1/1] i2c: mvtwsi.c: Avoid NULL dereference

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Jan 30 23:57:17 UTC 2018


For '#ifndef CONFIG_DM_I2C' twsi_i2c_init() passes NULL as
4th parameter to __twsi_i2c_init().

Identified with cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 drivers/i2c/mvtwsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index dfbc4e053f..30bee0d52e 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -490,7 +490,8 @@ static void __twsi_i2c_init(struct mvtwsi_registers *twsi, int speed,
 	/* Reset controller */
 	twsi_reset(twsi);
 	/* Set speed */
-	*actual_speed = __twsi_i2c_set_bus_speed(twsi, speed);
+	if (actual_speed)
+		*actual_speed = __twsi_i2c_set_bus_speed(twsi, speed);
 	/* Set slave address; even though we don't use it */
 	writel(slaveadd, &twsi->slave_address);
 	writel(0, &twsi->xtnd_slave_addr);
-- 
2.15.1



More information about the U-Boot mailing list