Re: [PATCH] i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
> Cc: Andy Shevchenko <andy@xxxxxxxxxxxxx>
> Cc: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> Fixes: d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
> ---
>  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@xxxxxxx>

-- 
Jean Delvare
SUSE L3 Support



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux