i2c: i801: Fix the i2c-mux gpiod_lookup_table not being properly terminated
authorHans de Goede <hdegoede@redhat.com>
Mon, 21 Dec 2020 13:42:25 +0000 (14:42 +0100)
committerWolfram Sang <wsa@kernel.org>
Mon, 4 Jan 2021 18:25:02 +0000 (19:25 +0100)
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.

Fixes: d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-i801.c

index ae90713443fa61aa1644fcb80412a500c23ed2c1..877fe3733a42b211f7fd039a305fa39ef0e270dd 100644 (file)
@@ -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;