Re: [PATCH] iio: light: apds9306: fix PM reference leak in apds9306_read_data()

From: Subhajit Ghosh

Date: Sat Aug 01 2026 - 04:48:39 EST


On 27/7/26 12:01 pm, Jonathan Cameron wrote:
On Sat, 25 Jul 2026 05:10:48 +0000
Moksh Panicker <mokshpanicker.7@xxxxxxxxx> wrote:

apds9306_read_data() calls pm_runtime_resume_and_get() but several
error paths return directly without calling pm_runtime_put_autosuspend(),
leaking the runtime PM reference and preventing the device from
autosuspending.

Add a goto label before pm_runtime_put_autosuspend() and use it on
all error paths after a successful pm_runtime_resume_and_get().

Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Moksh Panicker <mokshpanicker.7@xxxxxxxxx>
Good find.
Please look at PM_RUNTIME_ACQUIRE_AUTOSUSPEND() and matching ERR macro.

Using that should simplify this fix quite a bit and generally give us nicer code.

Nice. Ditto. I have to read about it too. Thanks Jonathan.