Skip to content

Commit 147d5bf

Browse files
committed
i2c: i801: Avoid potential double call to gpiod_remove_lookup_table
JIRA: https://issues.redhat.com/browse/RHEL-47426 commit ceb013b Author: Heiner Kallweit <hkallweit1@gmail.com> Date: Mon Mar 4 21:31:06 2024 +0100 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> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent 5c18790 commit 147d5bf

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
@@ -1432,7 +1432,6 @@ static void i801_add_mux(struct i801_priv *priv)
14321432
lookup->table[i] = GPIO_LOOKUP(mux_config->gpio_chip,
14331433
mux_config->gpios[i], "mux", 0);
14341434
gpiod_add_lookup_table(lookup);
1435-
priv->lookup = lookup;
14361435

14371436
/*
14381437
* Register the mux device, we use PLATFORM_DEVID_NONE here
@@ -1446,7 +1445,10 @@ static void i801_add_mux(struct i801_priv *priv)
14461445
sizeof(struct i2c_mux_gpio_platform_data));
14471446
if (IS_ERR(priv->mux_pdev)) {
14481447
gpiod_remove_lookup_table(lookup);
1448+
devm_kfree(dev, lookup);
14491449
dev_err(dev, "Failed to register i2c-mux-gpio device\n");
1450+
} else {
1451+
priv->lookup = lookup;
14501452
}
14511453
}
14521454

0 commit comments

Comments
 (0)