* [PATCH] Input: ili210x - widen firmware address types to u32
@ 2026-11-29 9:03 Aibing Chen
2026-11-29 9:11 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Aibing Chen @ 2026-11-29 9:03 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-kernel, Aibing Chen, sashiko-bot
The firmware write command uses a 3-byte address field, but the
address variables (end, start, fw_addr, ac_end, df_end) are typed as
u16, which truncates addresses at 0xffff. The firmware blob validation
allows the last block to end at SZ_64K (0x10000), so df_end can be
0x10000 -- which truncates to 0 in a u16, making the upper byte of the
3-byte address always 0.
Widen the address types to u32 so that the full 3-byte address range
is usable and the upper byte in the write command reflects the actual
address. For the CRC field, write 0x00 for the upper byte directly:
CRC-CCITT always produces a 16-bit value, so the upper byte is
constant, which also silences the Smatch warning about shifting a
16-bit value by 16.
Suggested-by: sashiko-bot <sashiko-bot@kernel.org>
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
drivers/input/touchscreen/ili210x.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 03e4451d6..2e4681813 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -595,7 +595,7 @@ static ssize_t ili210x_calibrate(struct device *dev,
static DEVICE_ATTR(calibrate, S_IWUSR, NULL, ili210x_calibrate);
static const u8 *ili251x_firmware_to_buffer(const struct firmware *fw,
- u16 *ac_end, u16 *df_end)
+ u32 *ac_end, u32 *df_end)
{
const struct ihex_binrec *rec;
u32 fw_addr, fw_last_addr = 0;
@@ -696,14 +696,14 @@ static int ili251x_firmware_busy(struct i2c_client *client)
}
static int ili251x_firmware_write_to_ic(struct device *dev, const u8 *fwbuf,
- u16 start, u16 end, u8 dataflash)
+ u32 start, u32 end, u8 dataflash)
{
struct i2c_client *client = to_i2c_client(dev);
struct ili210x *priv = i2c_get_clientdata(client);
u8 cmd_crc = REG_READ_DATA_CRC;
u8 crcrb[4] = { 0 };
u8 fw_data[33];
- u16 fw_addr;
+ u32 fw_addr;
int error;
/*
@@ -717,7 +717,7 @@ static int ili251x_firmware_write_to_ic(struct device *dev, const u8 *fwbuf,
u8 cmd_wr[10] = {
REG_WRITE_ENABLE, 0x5a, 0xa5, dataflash,
(end >> 16) & 0xff, (end >> 8) & 0xff, end & 0xff,
- (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff
+ 0x00, (crc >> 8) & 0xff, crc & 0xff
};
error = i2c_master_send(client, cmd_wr, sizeof(cmd_wr));
@@ -781,7 +781,7 @@ static void ili210x_hardware_reset(struct gpio_desc *reset_gpio)
}
static int ili210x_do_firmware_update(struct ili210x *priv,
- const u8 *fwbuf, u16 ac_end, u16 df_end)
+ const u8 *fwbuf, u32 ac_end, u32 df_end)
{
struct i2c_client *client = priv->client;
struct device *dev = &client->dev;
@@ -868,7 +868,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
const char *fwname = ILI251X_FW_FILENAME;
- u16 ac_end, df_end;
+ u32 ac_end, df_end;
int error;
const struct firmware *fw __free(firmware) = NULL;
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Input: ili210x - widen firmware address types to u32
2026-11-29 9:03 [PATCH] Input: ili210x - widen firmware address types to u32 Aibing Chen
@ 2026-11-29 9:11 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-29 9:11 UTC (permalink / raw)
To: Aibing Chen; +Cc: linux-input, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] Input: ili210x - u16 parameters in ili210x_firmware_update()
truncate end addresses
- [Low] Input: ili210x - missing Fixes trailer for u16 firmware address
truncation
--
commit 367981bad9bc63de88c9f1f6d4141cec44ab2560
Author: Aibing Chen <chenaibing@cmss.chinamobile.com>
> Input: ili210x - widen firmware address types to u32
>
> The firmware write command uses a 3-byte address field, but the
> address variables (end, start, fw_addr, ac_end, df_end) are typed as
> u16, which truncates addresses at 0xffff. The firmware blob validation
> allows the last block to end at SZ_64K (0x10000), so df_end can be
> 0x10000 -- which truncates to 0 in a u16, making the upper byte of the
> 3-byte address always 0.
>
> Widen the address types to u32 so that the full 3-byte address range
> is usable and the upper byte in the write command reflects the actual
> address. For the CRC field, write 0x00 for the upper byte directly:
> CRC-CCITT always produces a 16-bit value, so the upper byte is
> constant, which also silences the Smatch warning about shifting a
> 16-bit value by 16.
>
> Suggested-by: sashiko-bot <sashiko-bot@kernel.org>
> Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
[Severity: Low]
This fixes a bug in ili251x firmware update support. Should this
include:
Fixes: c6ac8f0b4ca9 ("Input: ili210x - add ili251x firmware update support")
> diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
> index 03e4451d6393c..2e4681813731b 100644
> --- a/drivers/input/touchscreen/ili210x.c
> +++ b/drivers/input/touchscreen/ili210x.c
[ ... ]
> @@ -868,7 +868,7 @@ static ssize_t ili210x_firmware_update_store(struct device *dev,
> {
> struct i2c_client *client = to_i2c_client(dev);
> const char *fwname = ILI251X_FW_FILENAME;
> - u16 ac_end, df_end;
> + u32 ac_end, df_end;
> int error;
>
> const struct firmware *fw __free(firmware) = NULL;
[Severity: High]
Does ili210x_firmware_update() still truncate ac_end and df_end to u16?
ili210x_firmware_update_store() passes ac_end and df_end through
ili210x_firmware_update() before reaching ili210x_do_firmware_update():
drivers/input/touchscreen/ili210x.c:ili210x_firmware_update() {
static ssize_t ili210x_firmware_update(struct device *dev, const u8 *fwbuf,
u16 ac_end, u16 df_end)
{
...
error = ili210x_do_firmware_update(priv, fwbuf, ac_end, df_end);
}
When df_end is SZ_64K (0x10000), ili210x_firmware_update() truncates it
back to 0. In ili251x_firmware_write_to_ic(), start is 0xf000 and end is
0, so the u32 length expression end - start - 2 wraps around to
0xffff0ffe and causes crc_ccitt() to read ~4 GiB out of bounds past the
64 KiB fwbuf buffer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129090341.1179-1-chenaibing@cmss.chinamobile.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 9:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 9:03 [PATCH] Input: ili210x - widen firmware address types to u32 Aibing Chen
2026-11-29 9:11 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox