Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: ili210x - avoid shifting 16-bit values by 16
@ 2026-11-29  7:32 Aibing Chen
  2026-11-29  7:43 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Aibing Chen @ 2026-11-29  7:32 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

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@intel.com>
Closes: https://lore.kernel.org/all/202112071130.VjoibOrG-lkp@intel.com/
Signed-off-by: Aibing Chen <chenaibing@cmss.chinamobile.com>
---
 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));



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  7:32 [PATCH] Input: ili210x - avoid shifting 16-bit values by 16 Aibing Chen
2026-11-29  7:43 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox