i2c: Remove redundant comparison in npcm_i2c_reg_slave
authorRand Deeb <rand.sec96@gmail.com>
Tue, 6 Feb 2024 19:42:01 +0000 (22:42 +0300)
committerAndi Shyti <andi.shyti@kernel.org>
Wed, 14 Feb 2024 21:51:54 +0000 (22:51 +0100)
In the npcm_i2c_reg_slave() function, there was a redundant
comparison that checked if 'bus->slave' was null immediately after
assigning it the 'client' value. There were concerns about a
potential null dereference because of `client->adapter`, but
according to Wolfram Sang, "we trusted ourselves here" Therefore,
this comparison is unnecessary.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
drivers/i2c/busses/i2c-npcm7xx.c

index 54181b3f1919625a83010efbb7b439f8fd2316b7..2fe68615942efeb3b3b6d8df28ac53a1a38d4136 100644 (file)
@@ -1264,9 +1264,6 @@ static int npcm_i2c_reg_slave(struct i2c_client *client)
 
        bus->slave = client;
 
-       if (!bus->slave)
-               return -EINVAL;
-
        if (client->flags & I2C_CLIENT_TEN)
                return -EAFNOSUPPORT;