Re: [PATCH v2 3/3] iio: light: gp2ap002: Fix regulator leaks in runtime resume error path
Jonathan Cameron <[email protected]> Mon, 3 Aug 2026 01:27:38 +0100
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260803012738.2abf14db@jic23-huawei> |
On Wed, 22 Jul 2026 21:52:47 +0530 Nikhil Gautam <[email protected]> wrote: > If enabling vio fails, vdd is left enabled; if re-initializing the > sensor fails, both regulators are left enabled. > > unwind previously enabled regulators on failure, mirroring the error > handling already used in probe. > > Fixes: 97d642e23037c ("iio: light: Add a driver for Sharp GP2AP002x00F") > Signed-off-by: Nikhil Gautam <[email protected]> I'm already carrying this fix via a patch from Laxman, so dropping this one. Applied 1 and 2 but there was some noise due to other changes near this code so please take a look. Applied to the fixes-togreg branch of iio.git Thanks Jonathan > --- > drivers/iio/light/gp2ap002.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c > index e8ba9c00dabb..430336b51f83 100644 > --- a/drivers/iio/light/gp2ap002.c > +++ b/drivers/iio/light/gp2ap002.c > @@ -677,7 +677,7 @@ static int gp2ap002_runtime_resume(struct device *dev) > ret = regulator_enable(gp2ap002->vio); > if (ret) { > dev_err(dev, "failed to enable VIO regulator in resume path\n"); > - return ret; > + goto out_disable_vdd; > } > > msleep(20); > @@ -685,13 +685,19 @@ static int gp2ap002_runtime_resume(struct device *dev) > ret = gp2ap002_init(gp2ap002); > if (ret) { > dev_err(dev, "re-initialization failed\n"); > - return ret; > + goto out_disable_vio; > } > > /* Re-activate the IRQ */ > enable_irq(gp2ap002->irq); > > return 0; > + > +out_disable_vio: > + regulator_disable(gp2ap002->vio); > +out_disable_vdd: > + regulator_disable(gp2ap002->vdd); > + return ret; > } > > static DEFINE_RUNTIME_DEV_PM_OPS(gp2ap002_dev_pm_ops, gp2ap002_runtime_suspend,