[PATCH linux dev-6.6 v1 1/8] i2c: Remove redundant comparison in npcm_i2c_reg_slave

Tomer Maimon tmaimon77 at gmail.com
Tue Feb 4 03:14:43 AEDT 2025


From: Rand Deeb <rand.sec96 at gmail.com>

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 at gmail.com>
Reviewed-by: Wolfram Sang <wsa+renesas at sang-engineering.com>
Signed-off-by: Andi Shyti <andi.shyti at kernel.org>
---
 drivers/i2c/busses/i2c-npcm7xx.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
index ae4bae63ad4f..a28699b680f7 100644
--- a/drivers/i2c/busses/i2c-npcm7xx.c
+++ b/drivers/i2c/busses/i2c-npcm7xx.c
@@ -1265,9 +1265,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;
 
-- 
2.34.1



More information about the openbmc mailing list