All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Crofts <joshua.crofts1@gmail.com>
To: Vidhu Sarwal <vidhu.linux@gmail.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, shreeya.patel@collabora.com,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	skhan@linuxfoundation.org, linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH] iio: light: ltrf216a: fix runtime PM reference leak in error path
Date: Mon, 13 Jul 2026 14:28:09 +0200	[thread overview]
Message-ID: <20260713142809.000058ef@gmail.com> (raw)
In-Reply-To: <20260713022829.234370-1-vidhu.linux@gmail.com>

On Mon, 13 Jul 2026 07:58:29 +0530
Vidhu Sarwal <vidhu.linux@gmail.com> wrote:

> ltrf216a_get_lux() acquires a runtime PM reference by calling
> ltrf216a_set_power_state(data, true). However, if
> ltrf216a_read_data() fails, the function returns immediately without
> dropping the reference.
> 
> This leaves the runtime PM usage count unbalanced, preventing the device
> from autosuspending after a failed read.
> 
> Fix this by releasing the runtime PM reference before returning from the
> error path.
> 
> Fixes: 83f0bcd40d5c ("iio: light: Add support for ltrf216a sensor")
> Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
> ---
>  drivers/iio/light/ltrf216a.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/ltrf216a.c b/drivers/iio/light/ltrf216a.c
> index 3f34ddc911b4..3ec239eb5831 100644
> --- a/drivers/iio/light/ltrf216a.c
> +++ b/drivers/iio/light/ltrf216a.c
> @@ -247,8 +247,10 @@ static int ltrf216a_get_lux(struct ltrf216a_data *data)
>  		return ret;
>  
>  	greendata = ltrf216a_read_data(data, LTRF216A_ALS_DATA_0);
> -	if (greendata < 0)
> +	if (greendata < 0) {
> +		ltrf216a_set_power_state(data, false);
>  		return greendata;
> +	}
>  
>  	ltrf216a_set_power_state(data, false);

LGTM, Sashiko had an issue with the fact that pm_runtime_mark_last_busy() isn't
called before autosuspending, however pm_runtime_put_autosuspend() already calls
this function in its body.

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards

CJD

  reply	other threads:[~2026-07-13 12:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13  2:28 [PATCH] iio: light: ltrf216a: fix runtime PM reference leak in error path Vidhu Sarwal
2026-07-13 12:28 ` Joshua Crofts [this message]
2026-07-13 12:36 ` Andy Shevchenko

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=20260713142809.000058ef@gmail.com \
    --to=joshua.crofts1@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=shreeya.patel@collabora.com \
    --cc=skhan@linuxfoundation.org \
    --cc=vidhu.linux@gmail.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.