Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: light: ltrf216a: fix runtime PM reference leak in error path
@ 2026-07-13  2:28 Vidhu Sarwal
  2026-07-13 12:28 ` Joshua Crofts
  2026-07-13 12:36 ` Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Vidhu Sarwal @ 2026-07-13  2:28 UTC (permalink / raw)
  To: jic23
  Cc: linux-iio, linux-kernel, shreeya.patel, dlechner, nuno.sa, andy,
	skhan, linux-kernel-mentees, Vidhu Sarwal

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);
 

base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-13 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox