From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Kittisak Boonmapa <goorock.goopop@gmail.com>, jic23@kernel.org
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
sakari.ailus@linux.intel.com, joshua.crofts1@gmail.com
Subject: Re: [PATCH] iio: hid-sensors: Fix poll_value sign check before msleep_interruptible
Date: Wed, 01 Jul 2026 10:42:12 -0700 [thread overview]
Message-ID: <2543d1a196bb97f2e4ddeb8e6902392e8e1c9324.camel@linux.intel.com> (raw)
In-Reply-To: <20260701154319.23497-1-goorock.goopop@gmail.com>
On Wed, 2026-07-01 at 22:43 +0700, Kittisak Boonmapa wrote:
> hid_sensor_read_poll_value() returns -EINVAL when the HID descriptor
> does not contain a Report Interval feature field.
>
> _hid_sensor_power_state() currently treats any non-zero value as a
> valid delay and passes it to msleep_interruptible(). Since
> msleep_interruptible() takes an unsigned int, negative values are
> converted into very large delays.
>
> Only sleep when poll_value is positive.
>
> Fixes: 5d9854eaea77 ("iio: hid-sensor: Store restore poll and
> hysteresis on S3")
> Closes:
> https://lore.kernel.org/linux-iio/CAPr6G1qLDrgHvCNsVxj7xHxYUKkAkyo87Hq3Lfyoj3RaZ2v4dg@mail.gmail.com/
> Reported-by: Kittisak Boonmapa <goorock.goopop@gmail.com>
> Assisted-by: Anthropic:Claude Sonnet 4.6
> Signed-off-by: Kittisak Boonmapa <goorock.goopop@gmail.com>
>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> The bug was discovered while implementing a custom USB HID Sensor
> (Accelerometer 3D, HID Usage 0x200073) on a Seeed XIAO nRF52840 Sense
> for use with the Linux IIO subsystem and iio-sensor-proxy.
>
> The device intentionally omitted the Report Interval feature from its
> HID descriptor. This causes hid_sensor_read_poll_value() to return
> -EINVAL, which is then treated as a non-zero delay by
> _hid_sensor_power_state() and passed directly to
> msleep_interruptible(). Since msleep_interruptible() takes an
> unsigned int, the negative value is converted into an unintended
> sleep of approximately 49.7 days.
>
> The issue was reproduced consistently on a Steam Deck LCD running
> Bazzite (Linux 6.17.x), and disappeared completely after adding the
> Report Interval feature to the HID descriptor, confirming the root
> cause.
Although Report interval is an optional field, every hub had it from
the beginning.
But this change is good.
Thanks,
Srinivas
>
> This patch changes the condition to sleep only when poll_value is
> strictly positive, avoiding unintended delays while preserving the
> existing behavior for valid poll intervals.
>
> drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> index 417c4ab8c1b2..20099614bb27 100644
> --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
> @@ -143,7 +143,7 @@ static int _hid_sensor_power_state(struct
> hid_sensor_common *st, bool state)
> sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
> st->power_state.index,
> sizeof(state_val), &state_val);
> - if (state && poll_value)
> + if (state && poll_value > 0)
> msleep_interruptible(poll_value * 2);
>
> return 0;
next prev parent reply other threads:[~2026-07-01 17:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 15:43 [PATCH] iio: hid-sensors: Fix poll_value sign check before msleep_interruptible Kittisak Boonmapa
2026-07-01 15:49 ` Andy Shevchenko
2026-07-01 16:22 ` Joshua Crofts
2026-07-01 17:42 ` srinivas pandruvada [this message]
2026-07-01 17:47 ` Jonathan Cameron
2026-07-01 17:59 ` srinivas pandruvada
2026-07-01 18:59 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2543d1a196bb97f2e4ddeb8e6902392e8e1c9324.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=goorock.goopop@gmail.com \
--cc=jic23@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.