]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
i2c: mvtwsi.c: Avoid NULL dereference
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 30 Jan 2018 23:57:17 +0000 (00:57 +0100)
committerHeiko Schocher <hs@denx.de>
Tue, 6 Feb 2018 06:02:32 +0000 (07:02 +0100)
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@gmx.de>
drivers/i2c/mvtwsi.c

index dfbc4e053f56683fae878fc5b7ba627480a60ef6..30bee0d52e598d281df2679c7a5a0bce7865e70a 100644 (file)
@@ -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);