From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Benson Leung <bleung@chromium.org>
Cc: Bryam Vargas <hexlabsecurity@proton.me>,
tzungbi@kernel.org, chrome-platform@lists.linux.dev,
tfiga@chromium.org, suleiman@chromium.org
Subject: [PATCH] platform/chrome: sensorhub: Fix dropped timestamp events and log spam
Date: Tue, 14 Jul 2026 06:52:02 +0000 [thread overview]
Message-ID: <20260714065202.3248017-1-tzungbi@kernel.org> (raw)
Commit 833740a2333c ("platform/chrome: sensorhub: Bound the EC-reported
sensor number") evaluated the `sensor_num` against the bounds limit even
for timestamp events. A timestamp event typically has a `sensor_num` of
0xff [1], causing the driver to flag it as invalid and skip to the next
event.
As a result, we'd see a flooding of "Invalid sensor number 255 from EC"
warning logs and these timestamp events were being dropped.
Additionally, the firmware only ORs the tablet mode flag [2] onto
timestamp events. Because the firmware strictly generates standalone
timestamps (without other flags like ODR or FLUSH), bypassing the bounds
check for anything containing the TIMESTAMP flag is safe and avoids
invalid array access.
Skip the bounds check for events carrying the
MOTIONSENSE_SENSOR_FLAG_TIMESTAMP flag.
[1] https://crrev.com/219ca6ef82ba266da788b673ee4ad50bd3ea1285/common/motion_sense_fifo.c#427
[2] https://crrev.com/219ca6ef82ba266da788b673ee4ad50bd3ea1285/common/motion_sense_fifo.c#296
Fixes: 833740a2333c ("platform/chrome: sensorhub: Bound the EC-reported sensor number")
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
drivers/platform/chrome/cros_ec_sensorhub_ring.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_sensorhub_ring.c b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
index 92941924c347..e0a1bc19dc7f 100644
--- a/drivers/platform/chrome/cros_ec_sensorhub_ring.c
+++ b/drivers/platform/chrome/cros_ec_sensorhub_ring.c
@@ -897,8 +897,12 @@ static void cros_ec_sensorhub_ring_handler(struct cros_ec_sensorhub *sensorhub)
for (in = sensorhub->resp->fifo_read.data, j = 0;
j < number_data; j++, in++) {
- /* Skip event if sensor_num from EC is out of bounds. */
- if (in->sensor_num >= sensorhub->sensor_num) {
+ /*
+ * Skip event if sensor_num from EC is out of bounds,
+ * unless it is a timestamp event.
+ */
+ if (!(in->flags & MOTIONSENSE_SENSOR_FLAG_TIMESTAMP) &&
+ in->sensor_num >= sensorhub->sensor_num) {
dev_warn_ratelimited(sensorhub->dev,
"Invalid sensor number %u from EC\n",
in->sensor_num);
--
2.55.0.795.g602f6c329a-goog
next reply other threads:[~2026-07-14 6:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 6:52 Tzung-Bi Shih [this message]
2026-07-14 11:54 ` [PATCH] platform/chrome: sensorhub: Fix dropped timestamp events and log spam Tzung-Bi Shih
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=20260714065202.3248017-1-tzungbi@kernel.org \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=hexlabsecurity@proton.me \
--cc=suleiman@chromium.org \
--cc=tfiga@chromium.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox