public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
@ 2020-12-21 13:42 Hans de Goede
  2020-12-21 13:55 ` Mika Westerberg
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Hans de Goede @ 2020-12-21 13:42 UTC (permalink / raw)
  To: Jean Delvare, Wolfram Sang
  Cc: Hans de Goede, linux-i2c, Serge Semin, Linus Walleij,
	Andy Shevchenko, Mika Westerberg

gpiod_add_lookup_table() expects the gpiod_lookup_table->table passed to
it to be terminated with a zero-ed out entry.

So we need to allocate one more entry then we will use.

Cc: Serge Semin <fancer.lancer@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andy@infradead.org>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Fixes: d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/i2c/busses/i2c-i801.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index ae90713443fa..877fe3733a42 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1449,7 +1449,7 @@ static int i801_add_mux(struct i801_priv *priv)
 
 	/* Register GPIO descriptor lookup table */
 	lookup = devm_kzalloc(dev,
-			      struct_size(lookup, table, mux_config->n_gpios),
+			      struct_size(lookup, table, mux_config->n_gpios + 1),
 			      GFP_KERNEL);
 	if (!lookup)
 		return -ENOMEM;
-- 
2.28.0


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

* Re: [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
  2020-12-21 13:42 [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated Hans de Goede
@ 2020-12-21 13:55 ` Mika Westerberg
  2020-12-21 15:12 ` Jean Delvare
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Mika Westerberg @ 2020-12-21 13:55 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Jean Delvare, Wolfram Sang, linux-i2c, Serge Semin, Linus Walleij,
	Andy Shevchenko

On Mon, Dec 21, 2020 at 02:42:25PM +0100, Hans de Goede wrote:
> gpiod_add_lookup_table() expects the gpiod_lookup_table->table passed to
> it to be terminated with a zero-ed out entry.
> 
> So we need to allocate one more entry then we will use.
> 
> Cc: Serge Semin <fancer.lancer@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

* Re: [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
  2020-12-21 13:42 [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated Hans de Goede
  2020-12-21 13:55 ` Mika Westerberg
@ 2020-12-21 15:12 ` Jean Delvare
  2020-12-27 22:41 ` Linus Walleij
  2021-01-04 18:26 ` Wolfram Sang
  3 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2020-12-21 15:12 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Wolfram Sang, linux-i2c, Serge Semin, Linus Walleij,
	Andy Shevchenko, Mika Westerberg

Hi Hans,

On Mon, 21 Dec 2020 14:42:25 +0100, Hans de Goede wrote:
> gpiod_add_lookup_table() expects the gpiod_lookup_table->table passed to
> it to be terminated with a zero-ed out entry.
> 
> So we need to allocate one more entry then we will use.
> 
> Cc: Serge Semin <fancer.lancer@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/i2c/busses/i2c-i801.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
> index ae90713443fa..877fe3733a42 100644
> --- a/drivers/i2c/busses/i2c-i801.c
> +++ b/drivers/i2c/busses/i2c-i801.c
> @@ -1449,7 +1449,7 @@ static int i801_add_mux(struct i801_priv *priv)
>  
>  	/* Register GPIO descriptor lookup table */
>  	lookup = devm_kzalloc(dev,
> -			      struct_size(lookup, table, mux_config->n_gpios),
> +			      struct_size(lookup, table, mux_config->n_gpios + 1),
>  			      GFP_KERNEL);
>  	if (!lookup)
>  		return -ENOMEM;

Good catch.

Acked-by: Jean Delvare <jdelvare@suse.de>

-- 
Jean Delvare
SUSE L3 Support

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

* Re: [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
  2020-12-21 13:42 [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated Hans de Goede
  2020-12-21 13:55 ` Mika Westerberg
  2020-12-21 15:12 ` Jean Delvare
@ 2020-12-27 22:41 ` Linus Walleij
  2021-01-04 18:26 ` Wolfram Sang
  3 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2020-12-27 22:41 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Jean Delvare, Wolfram Sang, linux-i2c, Serge Semin,
	Andy Shevchenko, Mika Westerberg

On Mon, Dec 21, 2020 at 2:42 PM Hans de Goede <hdegoede@redhat.com> wrote:

> gpiod_add_lookup_table() expects the gpiod_lookup_table->table passed to
> it to be terminated with a zero-ed out entry.
>
> So we need to allocate one more entry then we will use.
>
> Cc: Serge Semin <fancer.lancer@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
  2020-12-21 13:42 [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated Hans de Goede
                   ` (2 preceding siblings ...)
  2020-12-27 22:41 ` Linus Walleij
@ 2021-01-04 18:26 ` Wolfram Sang
  3 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2021-01-04 18:26 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Jean Delvare, linux-i2c, Serge Semin, Linus Walleij,
	Andy Shevchenko, Mika Westerberg

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

On Mon, Dec 21, 2020 at 02:42:25PM +0100, Hans de Goede wrote:
> gpiod_add_lookup_table() expects the gpiod_lookup_table->table passed to
> it to be terminated with a zero-ed out entry.
> 
> So we need to allocate one more entry then we will use.
> 
> Cc: Serge Semin <fancer.lancer@gmail.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Andy Shevchenko <andy@infradead.org>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Fixes: d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied to for-current, thanks!


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

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

end of thread, other threads:[~2021-01-04 18:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-21 13:42 [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated Hans de Goede
2020-12-21 13:55 ` Mika Westerberg
2020-12-21 15:12 ` Jean Delvare
2020-12-27 22:41 ` Linus Walleij
2021-01-04 18:26 ` Wolfram Sang

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