[PATCH] Input: ili210x - avoid shifting 16-bit values by 16
From: Aibing Chen
Date: Sun Nov 29 2026 - 02:33:01 EST
ili251x_firmware_write_to_ic() builds the write command with the upper
byte of the 16-bit address and CRC:
(end >> 16) & 0xff, ...
(crc >> 16) & 0xff, ...
Shifting a 16-bit value by its own width is undefined behavior, and
smatch has been reporting it since the firmware update support was
added:
drivers/input/touchscreen/ili210x.c:719 ili251x_firmware_write_to_ic()
warn: right shifting more than type allows 16 vs 16
Both values are 16-bit, so the upper byte is always zero, but the shift
itself has to be defined. Promote the values to unsigned int before
shifting them, which keeps the emitted command unchanged.
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/all/202112071130.VjoibOrG-lkp@xxxxxxxxx/
Signed-off-by: Aibing Chen <chenaibing@xxxxxxxxxxxxxxxxxxxx>
---
drivers/input/touchscreen/ili210x.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 03e4451d6..94e6db4d9 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -716,8 +716,10 @@ 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
+ ((unsigned int)end >> 16) & 0xff,
+ (end >> 8) & 0xff, end & 0xff,
+ ((unsigned int)crc >> 16) & 0xff,
+ (crc >> 8) & 0xff, crc & 0xff
};
error = i2c_master_send(client, cmd_wr, sizeof(cmd_wr));