* [PATCH] iio: accel: kxsd9: Fix runtime PM leak in kxsd9_write_raw()
@ 2026-09-16 16:12 Wentao Liang
2026-09-16 17:33 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Wentao Liang @ 2026-09-16 16:12 UTC (permalink / raw)
To: andy
Cc: dlechner, jic23, linusw, linux-iio, linux-kernel, nuno.sa,
Wentao Liang, stable
pm_runtime_get_sync() increments the usage counter even on failure, so
every successful call must be paired with a put. Rejecting an invalid
scale value returned early and skipped the paired
pm_runtime_put_autosuspend(), permanently preventing runtime suspend.
Fixes: 9a9a369d6178 ("iio: accel: kxsd9: Deploy system and runtime PM")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/iio/accel/kxsd9.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index 4717d80fc24a..1186d711f4d3 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -146,8 +146,10 @@ static int kxsd9_write_raw(struct iio_dev *indio_dev,
if (mask == IIO_CHAN_INFO_SCALE) {
/* Check no integer component */
- if (val)
+ if (val) {
+ pm_runtime_put_autosuspend(st->dev);
return -EINVAL;
+ }
ret = kxsd9_write_scale(indio_dev, val2);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: accel: kxsd9: Fix runtime PM leak in kxsd9_write_raw()
2026-09-16 16:12 [PATCH] iio: accel: kxsd9: Fix runtime PM leak in kxsd9_write_raw() Wentao Liang
@ 2026-09-16 17:33 ` Linus Walleij
2026-09-17 0:24 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2026-09-16 17:33 UTC (permalink / raw)
To: Wentao Liang
Cc: andy, dlechner, jic23, linux-iio, linux-kernel, nuno.sa, stable
On Wed, Sep 16, 2026 at 6:12 PM Wentao Liang <vulab@iscas.ac.cn> wrote:
> pm_runtime_get_sync() increments the usage counter even on failure, so
> every successful call must be paired with a put. Rejecting an invalid
> scale value returned early and skipped the paired
> pm_runtime_put_autosuspend(), permanently preventing runtime suspend.
>
> Fixes: 9a9a369d6178 ("iio: accel: kxsd9: Deploy system and runtime PM")
> Cc: stable@vger.kernel.org
It's NOT that important.
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: accel: kxsd9: Fix runtime PM leak in kxsd9_write_raw()
2026-09-16 17:33 ` Linus Walleij
@ 2026-09-17 0:24 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-09-17 0:24 UTC (permalink / raw)
To: Linus Walleij
Cc: Wentao Liang, andy, dlechner, linux-iio, linux-kernel, nuno.sa,
stable
On Wed, 16 Sep 2026 19:33:47 +0200
Linus Walleij <linusw@kernel.org> wrote:
> On Wed, Sep 16, 2026 at 6:12 PM Wentao Liang <vulab@iscas.ac.cn> wrote:
>
> > pm_runtime_get_sync() increments the usage counter even on failure, so
> > every successful call must be paired with a put. Rejecting an invalid
> > scale value returned early and skipped the paired
> > pm_runtime_put_autosuspend(), permanently preventing runtime suspend.
> >
> > Fixes: 9a9a369d6178 ("iio: accel: kxsd9: Deploy system and runtime PM")
> > Cc: stable@vger.kernel.org
>
> It's NOT that important.
Also not the current code...
static int kxsd9_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val,
int val2,
long mask)
{
int ret = -EINVAL;
struct kxsd9_state *st = iio_priv(indio_dev);
pm_runtime_get_sync(st->dev);
if (mask == IIO_CHAN_INFO_SCALE) {
/* Check no integer component */
if (val)
ret = -EINVAL;
else
ret = kxsd9_write_scale(indio_dev, val2);
}
pm_runtime_put_autosuspend(st->dev);
return ret;
}
Which could be improved via the ACQUIRE magic but none the less doesn't
have this bug. Was fixed back in June.
Jonathan
>
> > Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
>
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-17 0:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 16:12 [PATCH] iio: accel: kxsd9: Fix runtime PM leak in kxsd9_write_raw() Wentao Liang
2026-09-16 17:33 ` Linus Walleij
2026-09-17 0:24 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox