Skip to contentSkip to conversation

i2c: i801: Avoid potential double call to gpiod_remove_lookup_table

PATCH Superseded Heiner Kallweit 1 participant 2 messages Feb 23, 2024

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 leaving it to i801_del_mux() to clean up.

Fixes d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
---
 drivers/i2c/busses/i2c-i801.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i2c/busses/i2c-i801.c +1 -3
index 4b9d04f20..223cd2b84 100644
@@ -1457,10 +1457,8 @@ static void i801_add_mux(struct i801_priv *priv)
 	priv->mux_pdev = platform_device_register_data(dev, "i2c-mux-gpio",
 				PLATFORM_DEVID_NONE, &gpio_data,
 				sizeof(struct i2c_mux_gpio_platform_data));
-	if (IS_ERR(priv->mux_pdev)) {
-		gpiod_remove_lookup_table(lookup);
+	if (IS_ERR(priv->mux_pdev))
 		dev_err(dev, "Failed to register i2c-mux-gpio device\n");
-	}
 }
 
 static void i801_del_mux(struct i801_priv *priv)
Signature · 1 line
2.43.2
#1 lore raw
Quoted 17 lines · Heiner Kallweit

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 leaving it to i801_del_mux() to clean up.

Fixes d308dfbf62ef ("i2c: mux/i801: Switch to use descriptor passing")
---
 drivers/i2c/busses/i2c-i801.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/i2c/busses/i2c-i801.c +0 -0
index 4b9d04f20..223cd2b84 100644
@@ -1457,10 +1457,8 @@ static void i801_add_mux(struct i801_priv *priv)
 	priv->mux_pdev = platform_device_register_data(dev, "i2c-mux-gpio",

drivers/i2c/busses/i2c-i801.c static void i801_add_mux(struct i801_priv *priv) · line 1464

Quoted 10 lines
drivers/i2c/busses/i2c-i801.c +1 -3
 				PLATFORM_DEVID_NONE, &gpio_data,
 				sizeof(struct i2c_mux_gpio_platform_data));
-	if (IS_ERR(priv->mux_pdev)) {
-		gpiod_remove_lookup_table(lookup);
+	if (IS_ERR(priv->mux_pdev))
 		dev_err(dev, "Failed to register i2c-mux-gpio device\n");
-	}
 }
 
 static void i801_del_mux(struct i801_priv *priv)

Forgot to cc stable in both patches. I'll wait for other feedback and will submit a v2 afterwards.