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

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