All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-01-09 14:51 ` Rand Deeb
  0 siblings, 0 replies; 13+ messages in thread
From: Rand Deeb @ 2024-01-09 14:51 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, a potential NULL pointer dereference
issue occurs when 'client' is NULL. This patch adds a proper NULL check for
'client' at the beginning of the function to prevent undefined behavior.

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

Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
---
 drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
index c1b679737240..cfabfb50211d 100644
--- a/drivers/i2c/busses/i2c-npcm7xx.c
+++ b/drivers/i2c/busses/i2c-npcm7xx.c
@@ -1243,13 +1243,14 @@ static irqreturn_t npcm_i2c_int_slave_handler(struct npcm_i2c *bus)
 static int npcm_i2c_reg_slave(struct i2c_client *client)
 {
 	unsigned long lock_flags;
-	struct npcm_i2c *bus = i2c_get_adapdata(client->adapter);
-
-	bus->slave = client;
+	struct npcm_i2c *bus;
 
-	if (!bus->slave)
+	if (!client)
 		return -EINVAL;
 
+	bus = i2c_get_adapdata(client->adapter);
+	bus->slave = client;
+
 	if (client->flags & I2C_CLIENT_TEN)
 		return -EAFNOSUPPORT;
 
-- 
2.34.1


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

* [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-01-09 14:51 ` Rand Deeb
  0 siblings, 0 replies; 13+ messages in thread
From: Rand Deeb @ 2024-01-09 14:51 UTC (permalink / raw)
  To: Avi Fishman, Tomer Maimon, Tali Perry, Patrick Venture,
	Nancy Yuen, Benjamin Fair, openbmc, linux-i2c, linux-kernel
  Cc: voskresenski.stanislav, deeb.rand, lvc-project, Rand Deeb

In the npcm_i2c_reg_slave function, a potential NULL pointer dereference
issue occurs when 'client' is NULL. This patch adds a proper NULL check for
'client' at the beginning of the function to prevent undefined behavior.

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

Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
---
 drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
index c1b679737240..cfabfb50211d 100644
--- a/drivers/i2c/busses/i2c-npcm7xx.c
+++ b/drivers/i2c/busses/i2c-npcm7xx.c
@@ -1243,13 +1243,14 @@ static irqreturn_t npcm_i2c_int_slave_handler(struct npcm_i2c *bus)
 static int npcm_i2c_reg_slave(struct i2c_client *client)
 {
 	unsigned long lock_flags;
-	struct npcm_i2c *bus = i2c_get_adapdata(client->adapter);
-
-	bus->slave = client;
+	struct npcm_i2c *bus;
 
-	if (!bus->slave)
+	if (!client)
 		return -EINVAL;
 
+	bus = i2c_get_adapdata(client->adapter);
+	bus->slave = client;
+
 	if (client->flags & I2C_CLIENT_TEN)
 		return -EAFNOSUPPORT;
 
-- 
2.34.1


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

* Re: [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
  2024-01-09 14:51 ` Rand Deeb
@ 2024-01-10  8:43   ` Tali Perry
  -1 siblings, 0 replies; 13+ messages in thread
From: Tali Perry @ 2024-01-10  8:43 UTC (permalink / raw)
  To: Rand Deeb
  Cc: Avi Fishman, Tomer Maimon, Patrick Venture, Nancy Yuen,
	Benjamin Fair, openbmc, linux-i2c, linux-kernel, deeb.rand,
	lvc-project, voskresenski.stanislav

On Tue, Jan 9, 2024 at 4:52 PM Rand Deeb <rand.sec96@gmail.com> wrote:
>
> In the npcm_i2c_reg_slave function, a potential NULL pointer dereference
> issue occurs when 'client' is NULL. This patch adds a proper NULL check for
> 'client' at the beginning of the function to prevent undefined behavior.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
> ---
>  drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
> index c1b679737240..cfabfb50211d 100644
> --- a/drivers/i2c/busses/i2c-npcm7xx.c
> +++ b/drivers/i2c/busses/i2c-npcm7xx.c
> @@ -1243,13 +1243,14 @@ static irqreturn_t npcm_i2c_int_slave_handler(struct npcm_i2c *bus)
>  static int npcm_i2c_reg_slave(struct i2c_client *client)
>  {
>         unsigned long lock_flags;
> -       struct npcm_i2c *bus = i2c_get_adapdata(client->adapter);
> -
> -       bus->slave = client;
> +       struct npcm_i2c *bus;
>
> -       if (!bus->slave)
> +       if (!client)
>                 return -EINVAL;
>
> +       bus = i2c_get_adapdata(client->adapter);
> +       bus->slave = client;
> +
>         if (client->flags & I2C_CLIENT_TEN)
>                 return -EAFNOSUPPORT;
>
> --
> 2.34.1
>


Thanks for the patch!

Reviewed-by:tali.perry1@gmail.com

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

* Re: [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-01-10  8:43   ` Tali Perry
  0 siblings, 0 replies; 13+ messages in thread
From: Tali Perry @ 2024-01-10  8:43 UTC (permalink / raw)
  To: Rand Deeb
  Cc: lvc-project, voskresenski.stanislav, Benjamin Fair, Avi Fishman,
	Patrick Venture, openbmc, linux-kernel, linux-i2c, deeb.rand,
	Tomer Maimon

On Tue, Jan 9, 2024 at 4:52 PM Rand Deeb <rand.sec96@gmail.com> wrote:
>
> In the npcm_i2c_reg_slave function, a potential NULL pointer dereference
> issue occurs when 'client' is NULL. This patch adds a proper NULL check for
> 'client' at the beginning of the function to prevent undefined behavior.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
> ---
>  drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
> index c1b679737240..cfabfb50211d 100644
> --- a/drivers/i2c/busses/i2c-npcm7xx.c
> +++ b/drivers/i2c/busses/i2c-npcm7xx.c
> @@ -1243,13 +1243,14 @@ static irqreturn_t npcm_i2c_int_slave_handler(struct npcm_i2c *bus)
>  static int npcm_i2c_reg_slave(struct i2c_client *client)
>  {
>         unsigned long lock_flags;
> -       struct npcm_i2c *bus = i2c_get_adapdata(client->adapter);
> -
> -       bus->slave = client;
> +       struct npcm_i2c *bus;
>
> -       if (!bus->slave)
> +       if (!client)
>                 return -EINVAL;
>
> +       bus = i2c_get_adapdata(client->adapter);
> +       bus->slave = client;
> +
>         if (client->flags & I2C_CLIENT_TEN)
>                 return -EAFNOSUPPORT;
>
> --
> 2.34.1
>


Thanks for the patch!

Reviewed-by:tali.perry1@gmail.com

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

* Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
  2024-01-10  8:43   ` Tali Perry
@ 2024-01-10  9:23     ` Fedor Pchelkin
  -1 siblings, 0 replies; 13+ messages in thread
From: Fedor Pchelkin @ 2024-01-10  9:23 UTC (permalink / raw)
  To: Tali Perry
  Cc: Rand Deeb, lvc-project, voskresenski.stanislav, Benjamin Fair,
	Avi Fishman, Patrick Venture, openbmc, linux-kernel, Nancy Yuen,
	linux-i2c, deeb.rand, Tomer Maimon

On 24/01/10 10:43AM, Tali Perry wrote:
> On Tue, Jan 9, 2024 at 4:52 PM Rand Deeb <rand.sec96@gmail.com> wrote:
> >
> > In the npcm_i2c_reg_slave function, a potential NULL pointer dereference
> > issue occurs when 'client' is NULL. This patch adds a proper NULL check for
> > 'client' at the beginning of the function to prevent undefined behavior.
> >
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> >
> > Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
> > ---
> >  drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
> > index c1b679737240..cfabfb50211d 100644
> > --- a/drivers/i2c/busses/i2c-npcm7xx.c
> > +++ b/drivers/i2c/busses/i2c-npcm7xx.c
> > @@ -1243,13 +1243,14 @@ static irqreturn_t npcm_i2c_int_slave_handler(struct npcm_i2c *bus)
> >  static int npcm_i2c_reg_slave(struct i2c_client *client)
> >  {
> >         unsigned long lock_flags;
> > -       struct npcm_i2c *bus = i2c_get_adapdata(client->adapter);
> > -
> > -       bus->slave = client;
> > +       struct npcm_i2c *bus;
> >
> > -       if (!bus->slave)
> > +       if (!client)
> >                 return -EINVAL;
> >
> > +       bus = i2c_get_adapdata(client->adapter);
> > +       bus->slave = client;
> > +
> >         if (client->flags & I2C_CLIENT_TEN)
> >                 return -EAFNOSUPPORT;
> >
> > --
> > 2.34.1
> >
> 
> 
> Thanks for the patch!
> 
> Reviewed-by:tali.perry1@gmail.com

If I'm not missing something, npcm_i2c_reg_slave() is called via a
function pointer ->reg_slave here [1]. And seems `client` can't be NULL
there. Other drivers implementing ->reg_slave function don't check its
argument.

Maybe we should just drop `if (!bus->slave)` check?

[1]: https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-slave.c#L48

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

* Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-01-10  9:23     ` Fedor Pchelkin
  0 siblings, 0 replies; 13+ messages in thread
From: Fedor Pchelkin @ 2024-01-10  9:23 UTC (permalink / raw)
  To: Tali Perry
  Cc: voskresenski.stanislav, lvc-project, Avi Fishman,
	Patrick Venture, openbmc, Tomer Maimon, linux-kernel, linux-i2c,
	deeb.rand, Rand Deeb, Benjamin Fair

On 24/01/10 10:43AM, Tali Perry wrote:
> On Tue, Jan 9, 2024 at 4:52 PM Rand Deeb <rand.sec96@gmail.com> wrote:
> >
> > In the npcm_i2c_reg_slave function, a potential NULL pointer dereference
> > issue occurs when 'client' is NULL. This patch adds a proper NULL check for
> > 'client' at the beginning of the function to prevent undefined behavior.
> >
> > Found by Linux Verification Center (linuxtesting.org) with SVACE.
> >
> > Signed-off-by: Rand Deeb <rand.sec96@gmail.com>
> > ---
> >  drivers/i2c/busses/i2c-npcm7xx.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-npcm7xx.c b/drivers/i2c/busses/i2c-npcm7xx.c
> > index c1b679737240..cfabfb50211d 100644
> > --- a/drivers/i2c/busses/i2c-npcm7xx.c
> > +++ b/drivers/i2c/busses/i2c-npcm7xx.c
> > @@ -1243,13 +1243,14 @@ static irqreturn_t npcm_i2c_int_slave_handler(struct npcm_i2c *bus)
> >  static int npcm_i2c_reg_slave(struct i2c_client *client)
> >  {
> >         unsigned long lock_flags;
> > -       struct npcm_i2c *bus = i2c_get_adapdata(client->adapter);
> > -
> > -       bus->slave = client;
> > +       struct npcm_i2c *bus;
> >
> > -       if (!bus->slave)
> > +       if (!client)
> >                 return -EINVAL;
> >
> > +       bus = i2c_get_adapdata(client->adapter);
> > +       bus->slave = client;
> > +
> >         if (client->flags & I2C_CLIENT_TEN)
> >                 return -EAFNOSUPPORT;
> >
> > --
> > 2.34.1
> >
> 
> 
> Thanks for the patch!
> 
> Reviewed-by:tali.perry1@gmail.com

If I'm not missing something, npcm_i2c_reg_slave() is called via a
function pointer ->reg_slave here [1]. And seems `client` can't be NULL
there. Other drivers implementing ->reg_slave function don't check its
argument.

Maybe we should just drop `if (!bus->slave)` check?

[1]: https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-slave.c#L48

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

* Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
  2024-01-10  9:23     ` Fedor Pchelkin
@ 2024-02-03 20:44       ` Wolfram Sang
  -1 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2024-02-03 20:44 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Tali Perry, Rand Deeb, lvc-project, voskresenski.stanislav,
	Benjamin Fair, Avi Fishman, Patrick Venture, openbmc,
	linux-kernel, Nancy Yuen, linux-i2c, deeb.rand, Tomer Maimon

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


> If I'm not missing something, npcm_i2c_reg_slave() is called via a
> function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> there. Other drivers implementing ->reg_slave function don't check its
> argument.

Correct, we trust ourselves here.

> Maybe we should just drop `if (!bus->slave)` check?

Yes.


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

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

* Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-02-03 20:44       ` Wolfram Sang
  0 siblings, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2024-02-03 20:44 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: voskresenski.stanislav, Benjamin Fair, Avi Fishman,
	Patrick Venture, openbmc, Tomer Maimon, linux-kernel, Tali Perry,
	linux-i2c, deeb.rand, Rand Deeb, lvc-project

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


> If I'm not missing something, npcm_i2c_reg_slave() is called via a
> function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> there. Other drivers implementing ->reg_slave function don't check its
> argument.

Correct, we trust ourselves here.

> Maybe we should just drop `if (!bus->slave)` check?

Yes.


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

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

* Re: Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
  2024-02-03 20:44       ` Wolfram Sang
@ 2024-02-04  8:54         ` Fedor Pchelkin
  -1 siblings, 0 replies; 13+ messages in thread
From: Fedor Pchelkin @ 2024-02-04  8:54 UTC (permalink / raw)
  To: Wolfram Sang, Rand Deeb
  Cc: Tali Perry, lvc-project, voskresenski.stanislav, Benjamin Fair,
	Avi Fishman, Patrick Venture, openbmc, linux-kernel, Nancy Yuen,
	linux-i2c, deeb.rand, Tomer Maimon

On 24/02/03 09:44PM, Wolfram Sang wrote:
> 
> > If I'm not missing something, npcm_i2c_reg_slave() is called via a
> > function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> > there. Other drivers implementing ->reg_slave function don't check its
> > argument.
> 
> Correct, we trust ourselves here.
> 
> > Maybe we should just drop `if (!bus->slave)` check?
> 
> Yes.
> 

Okay, thanks for confirmation.

Rand, would you like to prepare the patch, please?


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

* Re: Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-02-04  8:54         ` Fedor Pchelkin
  0 siblings, 0 replies; 13+ messages in thread
From: Fedor Pchelkin @ 2024-02-04  8:54 UTC (permalink / raw)
  To: Wolfram Sang, Rand Deeb
  Cc: voskresenski.stanislav, Benjamin Fair, Avi Fishman,
	Patrick Venture, openbmc, Tomer Maimon, linux-kernel, Tali Perry,
	linux-i2c, deeb.rand, lvc-project

On 24/02/03 09:44PM, Wolfram Sang wrote:
> 
> > If I'm not missing something, npcm_i2c_reg_slave() is called via a
> > function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> > there. Other drivers implementing ->reg_slave function don't check its
> > argument.
> 
> Correct, we trust ourselves here.
> 
> > Maybe we should just drop `if (!bus->slave)` check?
> 
> Yes.
> 

Okay, thanks for confirmation.

Rand, would you like to prepare the patch, please?


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

* Re: Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
  2024-02-04  8:54         ` Fedor Pchelkin
  (?)
@ 2024-02-04 10:01         ` Rand Deeb
  -1 siblings, 0 replies; 13+ messages in thread
From: Rand Deeb @ 2024-02-04 10:01 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: voskresenski.stanislav, Benjamin Fair, Avi Fishman,
	Patrick Venture, openbmc, Tomer Maimon, linux-kernel, Tali Perry,
	Wolfram Sang, linux-i2c, deeb.rand, lvc-project

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

Hi Fedor!,

Sure, In fact, there were two scenarios from the beginning, either
redundant condition or potential NULL pointer dereference.I relied on
the condition to determine the type of issue because I did not find
it logical to add a useless condition, but based on the words Wolfram
Sang "we trust ourselves here." then the scenario will change to
redundant condition, so i'll write a new patch and send it in new
thread.

On Sun, Feb 4, 2024 at 11:54 AM Fedor Pchelkin <pchelkin@ispras.ru> wrote:

> On 24/02/03 09:44PM, Wolfram Sang wrote:
> >
> > > If I'm not missing something, npcm_i2c_reg_slave() is called via a
> > > function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> > > there. Other drivers implementing ->reg_slave function don't check its
> > > argument.
> >
> > Correct, we trust ourselves here.
> >
> > > Maybe we should just drop `if (!bus->slave)` check?
> >
> > Yes.
> >
>
> Okay, thanks for confirmation.
>
> Rand, would you like to prepare the patch, please?
>
>

[-- Attachment #2: Type: text/html, Size: 1487 bytes --]

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

* Re: Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
  2024-02-04  8:54         ` Fedor Pchelkin
@ 2024-02-04 10:12           ` Rand Deeb
  -1 siblings, 0 replies; 13+ messages in thread
From: Rand Deeb @ 2024-02-04 10:12 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Wolfram Sang, Tali Perry, lvc-project, voskresenski.stanislav,
	Benjamin Fair, Avi Fishman, Patrick Venture, openbmc,
	linux-kernel, Nancy Yuen, linux-i2c, deeb.rand, Tomer Maimon

On Sun, Feb 4, 2024 at 11:54 AM Fedor Pchelkin <pchelkin@ispras.ru> wrote:
>
> On 24/02/03 09:44PM, Wolfram Sang wrote:
> >
> > > If I'm not missing something, npcm_i2c_reg_slave() is called via a
> > > function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> > > there. Other drivers implementing ->reg_slave function don't check its
> > > argument.
> >
> > Correct, we trust ourselves here.
> >
> > > Maybe we should just drop `if (!bus->slave)` check?
> >
> > Yes.
> >
>
> Okay, thanks for confirmation.
>
> Rand, would you like to prepare the patch, please?
>

Hi Fedor!,

Sure, In fact, there were two scenarios from the beginning, either
redundant condition or potential NULL pointer dereference.I relied on
the condition to determine the type of issue because I did not find
it logical to add a useless condition, but based on the Wolfram Sang
words "we trust ourselves here." then the scenario will change to
redundant condition, so i'll write a new patch and send it in new
thread.

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

* Re: Re: Re: [lvc-project] [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave
@ 2024-02-04 10:12           ` Rand Deeb
  0 siblings, 0 replies; 13+ messages in thread
From: Rand Deeb @ 2024-02-04 10:12 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: voskresenski.stanislav, Benjamin Fair, Avi Fishman,
	Patrick Venture, openbmc, Tomer Maimon, linux-kernel, Tali Perry,
	Wolfram Sang, linux-i2c, deeb.rand, lvc-project

On Sun, Feb 4, 2024 at 11:54 AM Fedor Pchelkin <pchelkin@ispras.ru> wrote:
>
> On 24/02/03 09:44PM, Wolfram Sang wrote:
> >
> > > If I'm not missing something, npcm_i2c_reg_slave() is called via a
> > > function pointer ->reg_slave here [1]. And seems `client` can't be NULL
> > > there. Other drivers implementing ->reg_slave function don't check its
> > > argument.
> >
> > Correct, we trust ourselves here.
> >
> > > Maybe we should just drop `if (!bus->slave)` check?
> >
> > Yes.
> >
>
> Okay, thanks for confirmation.
>
> Rand, would you like to prepare the patch, please?
>

Hi Fedor!,

Sure, In fact, there were two scenarios from the beginning, either
redundant condition or potential NULL pointer dereference.I relied on
the condition to determine the type of issue because I did not find
it logical to add a useless condition, but based on the Wolfram Sang
words "we trust ourselves here." then the scenario will change to
redundant condition, so i'll write a new patch and send it in new
thread.

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

end of thread, other threads:[~2024-02-05 10:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 14:51 [PATCH] i2c: Fix NULL pointer dereference in npcm_i2c_reg_slave Rand Deeb
2024-01-09 14:51 ` Rand Deeb
2024-01-10  8:43 ` Tali Perry
2024-01-10  8:43   ` Tali Perry
2024-01-10  9:23   ` Re: [lvc-project] " Fedor Pchelkin
2024-01-10  9:23     ` Fedor Pchelkin
2024-02-03 20:44     ` Wolfram Sang
2024-02-03 20:44       ` Wolfram Sang
2024-02-04  8:54       ` Fedor Pchelkin
2024-02-04  8:54         ` Fedor Pchelkin
2024-02-04 10:01         ` Rand Deeb
2024-02-04 10:12         ` Rand Deeb
2024-02-04 10:12           ` Rand Deeb

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.