Re: [PATCH v1 4/4] iio: light: gp2ap002: fix runtime PM leak on read error
From: Jonathan Cameron
Date: Sun Jun 14 2026 - 09:27:32 EST
On Sun, 14 Jun 2026 12:45:49 +0530
Biren Pandya <birenpandya@xxxxxxxxx> wrote:
> gp2ap002_read_raw() calls pm_runtime_get_sync() before reading the
> lux value, but if gp2ap002_get_lux() fails, it returns directly. This
> skips the pm_runtime_put_autosuspend() call at the "out" label,
> permanently leaking a runtime PM reference and preventing the device
> from autosuspending.
>
> Replace the direct return with a "goto out" to ensure the reference
> is properly dropped on the error path.
>
> Signed-off-by: Biren Pandya <birenpandya@xxxxxxxxx>
Similar to patch one this would benefit from a follow up cleanup to
make use of the ACQUIRE macros.
This is good though, so applied to the fixes-togreg branch of iio.git
and marked for stable.
Thanks
Jonathan
> ---
> drivers/iio/light/gp2ap002.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
> index a0d8a58f2704..886accf5e859 100644
> --- a/drivers/iio/light/gp2ap002.c
> +++ b/drivers/iio/light/gp2ap002.c
> @@ -258,7 +258,7 @@ static int gp2ap002_read_raw(struct iio_dev *indio_dev,
> case IIO_LIGHT:
> ret = gp2ap002_get_lux(gp2ap002);
> if (ret < 0)
> - return ret;
> + goto out;
> *val = ret;
> ret = IIO_VAL_INT;
> goto out;