Skip to content

Commit ceb013b

Browse files
hkallweitWolfram Sang
authored andcommitted
i2c: i801: Avoid potential double call to gpiod_remove_lookup_table
If registering the platform device fails, the lookup table is removed in the error path. On module removal we would try to remove the lookup table again. Fix this by setting priv->lookup only if registering the platform device was successful. In addition free the memory allocated for the lookup table in the error path. Fixes: d308dfb ("i2c: mux/i801: Switch to use descriptor passing") Cc: stable@vger.kernel.org Reviewed-by: Andi Shyti <andi.shyti@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 09f0290 commit ceb013b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,6 @@ static void i801_add_mux(struct i801_priv *priv)
14161416
lookup->table[i] = GPIO_LOOKUP(mux_config->gpio_chip,
14171417
mux_config->gpios[i], "mux", 0);
14181418
gpiod_add_lookup_table(lookup);
1419-
priv->lookup = lookup;
14201419

14211420
/*
14221421
* Register the mux device, we use PLATFORM_DEVID_NONE here
@@ -1430,7 +1429,10 @@ static void i801_add_mux(struct i801_priv *priv)
14301429
sizeof(struct i2c_mux_gpio_platform_data));
14311430
if (IS_ERR(priv->mux_pdev)) {
14321431
gpiod_remove_lookup_table(lookup);
1432+
devm_kfree(dev, lookup);
14331433
dev_err(dev, "Failed to register i2c-mux-gpio device\n");
1434+
} else {
1435+
priv->lookup = lookup;
14341436
}
14351437
}
14361438

0 commit comments

Comments
 (0)