Skip to content

Commit fb109fb

Browse files
hao-yaojwrdegoede
authored andcommitted
platform/x86: int3472: Avoid crash in unregistering regulator gpio
When int3472 is loaded before GPIO driver, acpi_get_and_request_gpiod() failed but the returned gpio descriptor is not NULL, it will cause panic in later gpiod_put(), so set the gpio_desc to NULL in register error handling to avoid such crash. Signed-off-by: Hao Yao <[email protected]> Signed-off-by: Bingbu Cao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 061c228 commit fb109fb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/platform/x86/intel/int3472/clk_and_regulator.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
101101

102102
int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
103103
"int3472,clk-enable");
104-
if (IS_ERR(int3472->clock.ena_gpio))
105-
return dev_err_probe(int3472->dev, PTR_ERR(int3472->clock.ena_gpio),
106-
"getting clk-enable GPIO\n");
104+
if (IS_ERR(int3472->clock.ena_gpio)) {
105+
ret = PTR_ERR(int3472->clock.ena_gpio);
106+
int3472->clock.ena_gpio = NULL;
107+
return dev_err_probe(int3472->dev, ret, "getting clk-enable GPIO\n");
108+
}
107109

108110
if (polarity == GPIO_ACTIVE_LOW)
109111
gpiod_toggle_active_low(int3472->clock.ena_gpio);
@@ -199,8 +201,9 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
199201
int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
200202
"int3472,regulator");
201203
if (IS_ERR(int3472->regulator.gpio)) {
202-
dev_err(int3472->dev, "Failed to get regulator GPIO line\n");
203-
return PTR_ERR(int3472->regulator.gpio);
204+
ret = PTR_ERR(int3472->regulator.gpio);
205+
int3472->regulator.gpio = NULL;
206+
return dev_err_probe(int3472->dev, ret, "getting regulator GPIO\n");
204207
}
205208

206209
/* Ensure the pin is in output mode and non-active state */

0 commit comments

Comments
 (0)