public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: Remove redundant comparison in npcm_i2c_reg_slave
@ 2024-02-06 19:42 Rand Deeb
  2024-02-06 19:52 ` Wolfram Sang
  2024-02-14 22:25 ` Andi Shyti
  0 siblings, 2 replies; 3+ messages in thread
From: Rand Deeb @ 2024-02-06 19:42 UTC (permalink / raw)
  To: Avi Fishman, Tomer Maimon, Tali Perry, Patrick Venture,
	Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel
  Cc: deeb.rand, lvc-project, voskresenski.stanislav, Rand Deeb

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>
---
 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 c1b679737240..bdf35b86e559 100644
--- a/drivers/i2c/busses/i2c-npcm7xx.c
+++ b/drivers/i2c/busses/i2c-npcm7xx.c
@@ -1247,9 +1247,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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: Remove redundant comparison in npcm_i2c_reg_slave
  2024-02-06 19:42 [PATCH] i2c: Remove redundant comparison in npcm_i2c_reg_slave Rand Deeb
@ 2024-02-06 19:52 ` Wolfram Sang
  2024-02-14 22:25 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2024-02-06 19:52 UTC (permalink / raw)
  To: Rand Deeb
  Cc: Avi Fishman, Tomer Maimon, Tali Perry, Patrick Venture,
	Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel,
	deeb.rand, lvc-project, voskresenski.stanislav

[-- Attachment #1: Type: text/plain, Size: 619 bytes --]

On Tue, Feb 06, 2024 at 10:42:01PM +0300, Rand Deeb wrote:
> 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>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: Remove redundant comparison in npcm_i2c_reg_slave
  2024-02-06 19:42 [PATCH] i2c: Remove redundant comparison in npcm_i2c_reg_slave Rand Deeb
  2024-02-06 19:52 ` Wolfram Sang
@ 2024-02-14 22:25 ` Andi Shyti
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Shyti @ 2024-02-14 22:25 UTC (permalink / raw)
  To: Avi Fishman, Tomer Maimon, Tali Perry, Patrick Venture,
	Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel,
	Rand Deeb
  Cc: deeb.rand, lvc-project, voskresenski.stanislav

Hi

On Tue, 06 Feb 2024 22:42:01 +0300, Rand Deeb wrote:
> 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.
> 
> [...]

Applied to i2c/i2c-host on

git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Thank you,
Andi

Patches applied
===============
[1/1] i2c: Remove redundant comparison in npcm_i2c_reg_slave
      commit: 48acf8292280f257fb0047478153a81471ee7f4d


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-14 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 19:42 [PATCH] i2c: Remove redundant comparison in npcm_i2c_reg_slave Rand Deeb
2024-02-06 19:52 ` Wolfram Sang
2024-02-14 22:25 ` Andi Shyti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox