i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
PATCH 1/1 i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
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.
--- drivers/i2c/busses/i2c-i801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-i801.c +1 -1
@@ -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 ;
Signature · 1 line
2.28.0
Quoted 9 lines · Hans de Goede
gpiod_add_lookup_table()expects thegpiod_lookup_table->tablepassed 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 <[email protected]>Cc Linus Walleij <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>
Hi Hans,
Quoted 20 lines · Hans de Goede
gpiod_add_lookup_table()expects thegpiod_lookup_table->tablepassed 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 <[email protected]>Cc Linus Walleij <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Fixes d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")Signed-off-by Hans de Goede <[email protected]>--- drivers/i2c/busses/i2c-i801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/busses/i2c-i801.c +0
-0
drivers/i2c/busses/i2c-i801.c static int i801_add_mux(struct i801_priv *priv) · line 1455
Quoted 8 lines
drivers/i2c/busses/i2c-i801.c +1
-1@@ -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.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Quoted 11 lines · Hans de Goede
gpiod_add_lookup_table()expects thegpiod_lookup_table->tablepassed 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 <[email protected]>Cc Linus Walleij <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Fixes d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")Signed-off-by Hans de Goede <[email protected]>
Yours,
Linus Walleij
Wolfram Sang
AppliedQuoted 11 lines · Hans de Goede
gpiod_add_lookup_table()expects thegpiod_lookup_table->tablepassed 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 <[email protected]>Cc Linus Walleij <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Mika Westerberg <[email protected]>Fixes d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")Signed-off-by Hans de Goede <[email protected]>
Applied to for-current, thanks!