From: sashiko-bot@kernel.org
To: "Kristian Mide" <kristian@mide.dk>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v2 2/3] Input: ilitek_ts: handle short I2C transfers
Date: Thu, 09 Jul 2026 18:37:33 +0000 [thread overview]
Message-ID: <20260709183734.084DA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709182602.7308-3-kristian@mide.dk>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing `enable_irq()` on error paths in suspend and resume functions.
- [High] Incorrect touch packet parsing offset across 64-byte chunks for points > 10.
--
--- Patch [2]: [PATCH v2 2/3] Input: ilitek_ts: handle short I2C transfers ---
commit fea6e8240af99ced183b54d3a3d2c69a63ac6791
Author: Kristian Mide <kristian@mide.dk>
Input: ilitek_ts: handle short I2C transfers
Check that i2c_transfer() returns the expected number of
messages in ilitek_i2c_write_and_read().
> diff --git a/drivers/input/touchscreen/ilitek_ts_i2c.c b/drivers/input/touchscreen/ilitek_ts_i2c.c
> index 54e39721f2473..6146baa2b6062 100644
> --- a/drivers/input/touchscreen/ilitek_ts_i2c.c
> +++ b/drivers/input/touchscreen/ilitek_ts_i2c.c
> @@ -131,11 +131,15 @@ static int ilitek_i2c_write_and_read(struct ilitek_ts_data *ts,
> error = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
> if (error < 0)
> return error;
> + if (error != ARRAY_SIZE(msgs))
> + return -EIO;
> } else {
> if (write_len > 0) {
> error = i2c_transfer(client->adapter, msgs, 1);
> if (error < 0)
> return error;
> + if (error != 1)
> + return -EIO;
> }
> if (delay > 0)
> fsleep(delay * 1000);
> @@ -144,6 +148,8 @@ static int ilitek_i2c_write_and_read(struct ilitek_ts_data *ts,
> error = i2c_transfer(client->adapter, msgs + 1, 1);
> if (error < 0)
> return error;
> + if (error != 1)
> + return -EIO;
> }
> }
drivers/input/touchscreen/ilitek_ts_i2c.c:ilitek_suspend() {
...
error = api_protocol_set_cmd(ts, SET_IC_SLEEP, NULL, NULL);
if (error)
return error;
...
}
[Severity: High]
This isn't a bug introduced by this patch, but does this error path return
early without re-enabling the IRQ that was disabled at the start of the
function?
If api_protocol_set_cmd() fails during system suspend or resume, the PM core
will abort the suspend process. Because enable_irq() is skipped, won't
ilitek_resume() not be called for this device, leaving the IRQ permanently
disabled and the device unresponsive?
drivers/input/touchscreen/ilitek_ts_i2c.c:ilitek_resume() {
...
error = api_protocol_set_cmd(ts, SET_IC_WAKE, NULL, NULL);
if (error)
return error;
...
}
[Severity: High]
This is a pre-existing issue, but does this error path also return early
before the enable_irq() call is reached?
drivers/input/touchscreen/ilitek_ts_i2c.c:ilitek_process_and_report_v6() {
...
status = buf[i * packet_len + 1] & 0x40;
if (!status)
continue;
id = buf[i * packet_len + 1] & 0x3F;
x = get_unaligned_le16(buf + i * packet_len + 2);
y = get_unaligned_le16(buf + i * packet_len + 4);
...
}
[Severity: High]
This isn't a bug introduced by this patch, but does this purely linear
index calculation i * packet_len cause out-of-bounds offsets into padding
areas and conflict with metadata offsets for indices >= 10?
The driver reads touch points into buf in 64-byte chunks, each holding up
to 10 touch points, and advances the buffer pointer by 64 bytes for each
chunk.
Because each chunk only uses 50 bytes of data (leaving 14 bytes of padding),
won't the linear formula fail to account for the 64-byte chunk boundaries
instead of correctly tracking them?
For example, for the 11th point (i = 10), the driver should read from
buf[64], but it incorrectly reads from buf[50] (which is inside the first
chunk's padding). For i = 12, the offset buf[12 * 5 + 1] resolves to 61,
colliding exactly with REPORT_COUNT_ADDRESS, resulting in corrupted
coordinates and statuses for points > 10.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709182602.7308-1-kristian@mide.dk?part=2
next prev parent reply other threads:[~2026-07-09 18:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 21:42 [PATCH 0/2] Input: ilitek_ts: add stylus support for 0x0c reports Kristian Mide
2026-06-26 21:42 ` [PATCH 1/2] Input: ilitek_ts: add stylus input support Kristian Mide
2026-06-26 21:56 ` sashiko-bot
2026-06-26 21:42 ` [PATCH 2/2] Input: ilitek_ts: ratelimit unexpected report logging Kristian Mide
2026-06-26 21:56 ` sashiko-bot
2026-07-09 18:25 ` [PATCH v2 0/3] Input: ilitek_ts: add stylus support for 0x0c reports Kristian Mide
2026-07-09 18:26 ` [PATCH v2 1/3] Input: ilitek_ts: add stylus input support Kristian Mide
2026-07-09 18:36 ` sashiko-bot
2026-07-09 18:26 ` [PATCH v2 2/3] Input: ilitek_ts: handle short I2C transfers Kristian Mide
2026-07-09 18:37 ` sashiko-bot [this message]
2026-07-09 18:26 ` [PATCH v2 3/3] Input: ilitek_ts: ratelimit unexpected report logging Kristian Mide
2026-07-09 18:40 ` sashiko-bot
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=20260709183734.084DA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=kristian@mide.dk \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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