* [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; 3+ 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] 3+ messages in thread
* Re: [PATCH] regulator: arizona-ldo1: Fix double gpiod_put() on enable GPIO
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
0 siblings, 1 reply; 3+ messages in thread
From: Charles Keepax @ 2026-11-05 10:02 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Liam Girdwood, Mark Brown, patches, linux-kernel, Linus Walleij
On Wed, Nov 04, 2026 at 10:38:32PM -0800, Dmitry Torokhov wrote:
> 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>
> ---
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: arizona-ldo1: Fix double gpiod_put() on enable GPIO
2026-11-05 10:02 ` Charles Keepax
@ 2026-11-05 10:08 ` Charles Keepax
0 siblings, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2026-11-05 10:08 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Liam Girdwood, Mark Brown, patches, linux-kernel, Linus Walleij
On Thu, Nov 05, 2026 at 10:02:00AM +0000, Charles Keepax wrote:
> On Wed, Nov 04, 2026 at 10:38:32PM -0800, Dmitry Torokhov wrote:
> > 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>
> > ---
>
> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Seems Lee has sent an almost identical patch:
https://lore.kernel.org/lkml/20261104182148.1176116-3-lee@kernel.org/
Perhaps we should go with that version as it also removes the
now redundant platform_set_drvdata.
Thanks,
Charles
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-05 10:08 UTC | newest]
Thread overview: 3+ 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
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®