mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] regulator: arizona-ldo1: Fix double gpiod_put() on enable GPIO
@ 2026-11-05  6:38 Dmitry Torokhov
  2026-11-05 10:02 ` Charles Keepax
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2026-11-05  6:38 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Charles Keepax
  Cc: patches, linux-kernel, Linus Walleij

When arizona-ldo1 registers the regulator, the regulator core takes
ownership of the GPIO descriptor passed in regulator_config.ena_gpiod.
The core frees this enable GPIO descriptor both on registration error
and when the regulator device is unregistered.

Because the driver also tracked the descriptor and called gpiod_put()
in its driver remove callback, unbinding the driver causes a duplicate
gpiod_put(). Remove the driver remove callback and stop storing the
enable GPIO descriptor in driver private data to avoid the double
free.

Fixes: a9191579ba10 ("regulator: arizona-ldo1: Use correct device to get enable GPIO")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/regulator/arizona-ldo1.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index 501843996faa..f719158ac360 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -35,8 +35,6 @@ struct arizona_ldo1 {
 
 	struct regulator_consumer_supply supply;
 	struct regulator_init_data init_data;
-
-	struct gpio_desc *ena_gpiod;
 };
 
 static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
@@ -262,8 +260,6 @@ static int arizona_ldo1_common_init(struct platform_device *pdev,
 	if (IS_ERR(config.ena_gpiod))
 		return PTR_ERR(config.ena_gpiod);
 
-	ldo1->ena_gpiod = config.ena_gpiod;
-
 	if (pdata->init_data)
 		config.init_data = pdata->init_data;
 	else
@@ -339,14 +335,6 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static void arizona_ldo1_remove(struct platform_device *pdev)
-{
-	struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev);
-
-	if (ldo1->ena_gpiod)
-		gpiod_put(ldo1->ena_gpiod);
-}
-
 static int madera_ldo1_probe(struct platform_device *pdev)
 {
 	struct madera *madera = dev_get_drvdata(pdev->dev.parent);
@@ -375,7 +363,6 @@ static int madera_ldo1_probe(struct platform_device *pdev)
 
 static struct platform_driver arizona_ldo1_driver = {
 	.probe = arizona_ldo1_probe,
-	.remove = arizona_ldo1_remove,
 	.driver = {
 		.name = "arizona-ldo1",
 		.probe_type = PROBE_FORCE_SYNCHRONOUS,
@@ -384,7 +371,6 @@ static struct platform_driver arizona_ldo1_driver = {
 
 static struct platform_driver madera_ldo1_driver = {
 	.probe = madera_ldo1_probe,
-	.remove = arizona_ldo1_remove,
 	.driver = {
 		.name = "madera-ldo1",
 		.probe_type = PROBE_FORCE_SYNCHRONOUS,

---
base-commit: d6bcfc94eb4da6e089c5473970cd96727292fd97
change-id: 20261104-arizona-ldo1-gpiod-fix-48e94fe22e18

Thanks.

-- 
Dmitry


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

end of thread, other threads:[~2026-11-05 16:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05  6:38 [PATCH] regulator: arizona-ldo1: Fix double gpiod_put() on enable GPIO Dmitry Torokhov
2026-11-05 10:02 ` Charles Keepax
2026-11-05 10:08   ` Charles Keepax
2026-11-05 16:41     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®