Input: ili210x - widen the firmware address types
Subsystems (2)
PATCH v2 1/1 Input: ili210x - widen the firmware address types
The firmware write command carries a 3-byte address, but the address variables are all u16, so an address of 0x10000 is truncated to 0. The firmware blob validation explicitly allows the last block to end at SZ_64K, so df_end can reach 0x10000 and the dataflash area is then never written.
Widen end, start, fw_addr, ac_end and df_end to u32, from the ihex parser down to ili210x_firmware_update(), so that the full 3-byte address range reaches the command. Use put_unaligned_be24() for the address and for the CRC instead of the open-coded byte shifts; the CRC is 16 bit, so its upper byte is the constant zero.
---
v2:
- widen the addresses in ili210x_firmware_update() as well.
- use put_unaligned_be24() instead of the shift and mask expressions.
- keep the Reported-by and Closes tags of the smatch report, supersede the earlier submission that only added casts.
--- drivers/input/touchscreen/ili210x.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/input/touchscreen/ili210x.c +9 -8
@@ -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;/*
@@ -716,10 +716,11 @@ static int ili251x_firmware_write_to_ic(struct device *dev, const u8 *fwbuf,/* Unlock write to either AC (application) or DF (dataflash) area */ 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 }; +put_unaligned_be24 (end, &cmd_wr[4 ]); +put_unaligned_be24 (crc, &cmd_wr[7 ]); + error =i2c_master_send (client, cmd_wr,sizeof (cmd_wr));if (error !=sizeof (cmd_wr))return -EINVAL ;
@@ -781,7 +782,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;
@@ -842,7 +843,7 @@ static int ili210x_do_firmware_update(struct ili210x *priv, }static ssize_t ili210x_firmware_update (struct device *dev,const u8 *fwbuf, -u16 ac_end,u16 df_end) +u32 ac_end,u32 df_end) {struct i2c_client *client =to_i2c_client (dev);struct ili210x *priv =i2c_get_clientdata (client);
@@ -868,7 +869,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;
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] Input: ili210x - missing Signed-off-by trailer in commit message --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] Input: ili210x - missing Signed-off-by trailer in commit message
--
commit b37cc900f57c44df663d60c1a8b3f926f69b5acf
Author: Aibing Chen <[email protected]>
Quoted 14 lines
Input: ili210x - widen the firmware address types
The firmware write command carries a 3-byte address, but the address variables are all u16, so an address of
0x10000is truncated to 0. The firmware blob validation explicitly allows the last block to end atSZ_64K, sodf_endcan reach0x10000and the dataflash area is then never written.Widen end, start,
fw_addr,ac_endanddf_endto u32, from the ihex parser down toili210x_firmware_update(), so that the full 3-byte address range reaches the command. Useput_unaligned_be24()for the address and for the CRC instead of the open-coded byte shifts; the CRC is 16 bit, so its upper byte is the constant zero.
Quoted 3 lines
Reported-by kernel test robot <[email protected]>Fixes c6ac8f0b4ca9 ("Input: ili210x - add ili251x firmware update support")
[Severity: High]
The Signed-off-by trailer was placed below the first "---" separator line under the v2 changelog notes, so git am strips it when applying the patch, leaving the commit message without a Signed-off-by trailer.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 12 lines · Aibing Chen
The firmware write command carries a 3-byte address, but the address variables are all u16, so an address of
0x10000is truncated to 0. The firmware blob validation explicitly allows the last block to end atSZ_64K, sodf_endcan reach0x10000and the dataflash area is then never written.Widen end, start,
fw_addr,ac_endanddf_endto u32, from the ihex parser down toili210x_firmware_update(), so that the full 3-byte address range reaches the command. Useput_unaligned_be24()for the address and for the CRC instead of the open-coded byte shifts; the CRC is 16 bit, so its upper byte is the constant zero.
Quoted 3 lines
Reported-by kernel test robot <[email protected]>Fixes c6ac8f0b4ca9 ("Input: ili210x - add ili251x firmware update support")
Applied, thank you.
Signature · 1 line
Dmitry