Re: [PATCH] iio: light: ltrf216a: fix runtime PM reference leak in error path
Joshua Crofts <[email protected]> Mon, 13 Jul 2026 14:28:09 +0200
| Newsgroups | dev.linux.lists.linux-kernel-mentees,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 13 Jul 2026 07:58:29 +0530 Vidhu Sarwal <[email protected]> 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 <[email protected]> > --- > 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 <[email protected]> -- Kind regards CJD