All of lore.kernel.org
 help / color / mirror / Atom feed
From: bingbu.cao@intel.com
To: djrscally@gmail.com, dan.scally@ideasonboard.com, hao.yao@intel.com
Cc: markgross@kernel.org, linux-media@vger.kernel.org,
	sakari.ailus@linux.intel.com, hdegoede@redhat.com,
	andriy.shevchenko@linux.intel.com, bingbu.cao@intel.com,
	bingbu.cao@linux.intel.com
Subject: [PATCH 1/3] platform/x86: int3472: Avoid crash in unregistering regulator gpio
Date: Wed, 24 May 2023 11:51:33 +0800	[thread overview]
Message-ID: <20230524035135.90315-1-bingbu.cao@intel.com> (raw)

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


             reply	other threads:[~2023-05-24  3:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24  3:51 bingbu.cao [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230524035135.90315-1-bingbu.cao@intel.com \
    --to=bingbu.cao@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bingbu.cao@linux.intel.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=djrscally@gmail.com \
    --cc=hao.yao@intel.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.