From: Andy Shevchenko <andriy.shevchenko@intel.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 15:36:51 +0300 [thread overview]
Message-ID: <alTb4-sg0ukY1aYI@ashevche-desk.local> (raw)
In-Reply-To: <20260713022829.234370-1-vidhu.linux@gmail.com>
On Mon, Jul 13, 2026 at 07:58:29AM +0530, Vidhu Sarwal 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.
...
> static int ltrf216a_get_lux(struct ltrf216a_data *data)
> 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);
Wouldn't be simpler to do
greendata = ltrf216a_read_data(data, LTRF216A_ALS_DATA_0);
ltrf216a_set_power_state(data, false);
if (greendata < 0)
return greendata;
?
Not insisting on this. Up to Jonathan and others to decide.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-07-13 12:37 UTC|newest]
Thread overview: 4+ 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
2026-07-13 12:36 ` Andy Shevchenko [this message]
2026-07-19 22:33 ` Jonathan Cameron
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=alTb4-sg0ukY1aYI@ashevche-desk.local \
--to=andriy.shevchenko@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox