linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] platform/x86: int3472: Avoid crash in unregistering regulator gpio
@ 2023-05-24  3:51 bingbu.cao
  2023-05-24  3:51 ` [PATCH 2/3] platform/x86: int3472: Evaluate device's _DSM method to control imaging clock bingbu.cao
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: bingbu.cao @ 2023-05-24  3:51 UTC (permalink / raw)
  To: djrscally, dan.scally, hao.yao
  Cc: markgross, linux-media, sakari.ailus, hdegoede,
	andriy.shevchenko, bingbu.cao, bingbu.cao

From: Hao Yao <hao.yao@intel.com>

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 <hao.yao@intel.com>
Signed-off-by: Bingbu Cao <bingbu.cao@intel.com>
---
 .../x86/intel/int3472/clk_and_regulator.c        | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
index 1086c3d83494..d1088be5af78 100644
--- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c
+++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
@@ -101,9 +101,12 @@ 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,clk-enable");
-	if (IS_ERR(int3472->clock.ena_gpio))
-		return dev_err_probe(int3472->dev, PTR_ERR(int3472->clock.ena_gpio),
-				     "getting clk-enable GPIO\n");
+	if (IS_ERR(int3472->clock.ena_gpio)) {
+		ret = PTR_ERR(int3472->clock.ena_gpio);
+		int3472->clock.ena_gpio = NULL;
+		return dev_err_probe(int3472->dev, ret,
+				     "failed to get gpio for clock\n");
+	}
 
 	if (polarity == GPIO_ACTIVE_LOW)
 		gpiod_toggle_active_low(int3472->clock.ena_gpio);
@@ -199,8 +202,11 @@ 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");
 	if (IS_ERR(int3472->regulator.gpio)) {
-		dev_err(int3472->dev, "Failed to get regulator GPIO line\n");
-		return PTR_ERR(int3472->regulator.gpio);
+		ret = PTR_ERR(int3472->regulator.gpio);
+		int3472->regulator.gpio = NULL;
+
+		return dev_err_probe(int3472->dev, ret,
+				     "failed to get regulator gpio\n");
 	}
 
 	/* Ensure the pin is in output mode and non-active state */
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-06-02  4:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24  3:51 [PATCH 1/3] platform/x86: int3472: Avoid crash in unregistering regulator gpio bingbu.cao
2023-05-24  3:51 ` [PATCH 2/3] platform/x86: int3472: Evaluate device's _DSM method to control imaging clock bingbu.cao
2023-05-24 10:31   ` Andy Shevchenko
2023-05-31 13:44   ` Hans de Goede
2023-06-01  6:24     ` Cao, Bingbu
2023-06-02  4:15       ` Yao, Hao
2023-05-24  3:51 ` [PATCH 3/3] platform/x86: int3472: Add ov13b10 (09B13) sensor module support bingbu.cao
2023-05-25 18:40   ` Hans de Goede
2023-05-31 15:18     ` Dan Scally
2023-05-31 15:34       ` Hans de Goede
     [not found]         ` <8183d5d6-8707-1ebb-4c47-49f35483fdc5@ideasonboard.com>
2023-06-01  8:33           ` Hans de Goede
2023-06-01  8:41             ` Dan Scally
2023-05-24 10:26 ` [PATCH 1/3] platform/x86: int3472: Avoid crash in unregistering regulator gpio Andy Shevchenko
2023-05-30 10:12 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).