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

Subhajit Ghosh <[email protected]> Sat, 1 Aug 2026 18:23:19 +0930
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel,org.kernel.vger.stable
Message-ID <[email protected]>
On 27/7/26 12:01 pm, Jonathan Cameron wrote:
> On Sat, 25 Jul 2026 05:10:48 +0000
> Moksh Panicker <[email protected]> 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: [email protected]
>> Signed-off-by: Moksh Panicker <[email protected]>
> 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.