Commit fb109fba authored by Hao Yao's avatar Hao Yao Committed by Hans de Goede

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: default avatarHao Yao <hao.yao@intel.com>
Signed-off-by: default avatarBingbu Cao <bingbu.cao@intel.com>
Link: https://lore.kernel.org/r/20230524035135.90315-1-bingbu.cao@intel.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 061c2289
...@@ -101,9 +101,11 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472, ...@@ -101,9 +101,11 @@ int skl_int3472_register_clock(struct int3472_discrete_device *int3472,
int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0], int3472->clock.ena_gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
"int3472,clk-enable"); "int3472,clk-enable");
if (IS_ERR(int3472->clock.ena_gpio)) if (IS_ERR(int3472->clock.ena_gpio)) {
return dev_err_probe(int3472->dev, PTR_ERR(int3472->clock.ena_gpio), ret = PTR_ERR(int3472->clock.ena_gpio);
"getting clk-enable GPIO\n"); int3472->clock.ena_gpio = NULL;
return dev_err_probe(int3472->dev, ret, "getting clk-enable GPIO\n");
}
if (polarity == GPIO_ACTIVE_LOW) if (polarity == GPIO_ACTIVE_LOW)
gpiod_toggle_active_low(int3472->clock.ena_gpio); gpiod_toggle_active_low(int3472->clock.ena_gpio);
...@@ -199,8 +201,9 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, ...@@ -199,8 +201,9 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472,
int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0], int3472->regulator.gpio = acpi_get_and_request_gpiod(path, agpio->pin_table[0],
"int3472,regulator"); "int3472,regulator");
if (IS_ERR(int3472->regulator.gpio)) { if (IS_ERR(int3472->regulator.gpio)) {
dev_err(int3472->dev, "Failed to get regulator GPIO line\n"); ret = PTR_ERR(int3472->regulator.gpio);
return PTR_ERR(int3472->regulator.gpio); int3472->regulator.gpio = NULL;
return dev_err_probe(int3472->dev, ret, "getting regulator GPIO\n");
} }
/* Ensure the pin is in output mode and non-active state */ /* Ensure the pin is in output mode and non-active state */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment