FAILED: patch "[PATCH] iio: light: apds9306: fix PM reference leak in" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x d378fceaafd79e0dc59d3546bda251a3058062c0
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090952-mollusk-copilot-9a29@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d378fceaafd79e0dc59d3546bda251a3058062c0 Mon Sep 17 00:00:00 2001
From: Moksh Panicker <[email protected]>
Date: Sun, 2 Aug 2026 19:07:01 +0000
Subject: [PATCH] iio: light: apds9306: fix PM reference leak in
apds9306_read_data()
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.
Use PM_RUNTIME_ACQUIRE_AUTOSUSPEND() and PM_RUNTIME_ACQUIRE_ERR() to automatically handle runtime PM reference release on all return paths.
drivers/iio/light/apds9306.c +3 -5
@@ -469,9 +469,9 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)int status =0 ;u8 buff[3 ]; - ret =pm_runtime_resume_and_get (data->dev); -if (ret) -return ret; +PM_RUNTIME_ACQUIRE_AUTOSUSPEND (data->dev, pm); +if (PM_RUNTIME_ACQUIRE_ERR (&pm)) +return PM_RUNTIME_ACQUIRE_ERR (&pm); ret =regmap_field_read (rf->intg_time, &intg_time_idx);if (ret)
@@ -535,8 +535,6 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) *val =get_unaligned_le24 (&buff); -pm_runtime_put_autosuspend (data->dev); -return 0 ; }
PATCH 1/1 iio: light: apds9306: fix PM reference leak in apds9306_read_data()
From: Moksh Panicker <[email protected]>
commit d378fceaafd79e0dc59d3546bda251a3058062c0 upstream.
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.
Use PM_RUNTIME_ACQUIRE_AUTOSUSPEND() and PM_RUNTIME_ACQUIRE_ERR() to automatically handle runtime PM reference release on all return paths.
---
This failed to apply to 6.12.y, which doesn't have the PM_RUNTIME_ACQUIRE_AUTOSUSPEND() helpers. Instead every error return after pm_runtime_resume_and_get() now jumps to the existing mark_last_busy()/put_autosuspend() at the end, so the usage count is dropped on all exits.
Tested on 6.12.119: W=1 build of apds9306.o, base vs patched, no new warnings, and the patched kernel boots under QEMU. No sensor here, so the read paths were checked in the source.
The backport and the test runs were prepared with AI coding tools (OpenAI Codex agents, with review by Claude). I went over the result before signing off.
--- drivers/iio/light/apds9306.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/iio/light/apds9306.c +11 -8
@@ -477,19 +477,21 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) ret =regmap_field_read (rf->intg_time, &intg_time_idx);if (ret) -return ret; + goto out_pm; ret =regmap_field_read (rf->repeat_rate, &repeat_rate_idx);if (ret) -return ret; + goto out_pm; ret =regmap_field_read (rf->int_src, &int_src);if (ret) -return ret; + goto out_pm; intg_time =iio_gts_find_int_time_by_sel (&data->gts, intg_time_idx); -if (intg_time <0 ) -return intg_time; +if (intg_time <0 ) { + ret = intg_time; + goto out_pm; + }/* Whichever is greater - integration time period or sampling period. */ delay =max (intg_time, apds9306_repeat_rate_period[repeat_rate_idx]);
@@ -512,7 +514,7 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) APDS9306_ALS_INT_STAT_MASK)), APDS9306_ALS_READ_DATA_DELAY_US, delay * 2);if (ret) -return ret; + goto out_pm;/* If we reach here before the interrupt handler we push an event */ if ((status &APDS9306_ALS_INT_STAT_MASK )) {
@@ -532,15 +534,16 @@ static int apds9306_read_data(struct apds9306_data *data, int *val, int reg) ret =regmap_bulk_read (data->regmap, reg, buff,sizeof (buff));if (ret) {dev_err_ratelimited (dev,"read data failed\n" ); -return ret; + goto out_pm; } *val =get_unaligned_le24 (&buff); +out_pm:pm_runtime_mark_last_busy (data->dev);pm_runtime_put_autosuspend (data->dev); -return 0 ; +return ret; }static int apds9306_intg_time_get (struct apds9306_data *data,int *val2)
---
base-commit: e2e4b92c2b2a3ae78423cb343951cb5d2241b405
change-id: 20261128-apds9306-612-123c3a7502e1
Best regards,
Signature · 1 line
Dickson Wu <[email protected]>
Re: [PATCH 6.12.y] iio: light: apds9306: fix PM reference leak in apds9306_read_data()
Quoted 1 line
[ adapted to 6.12.y: no
PM_RUNTIME_ACQUIREhelpers, goto the put ]
Queued for 6.12, thanks.
Signature · 2 lines
Thanks, Sasha