Skip to contentSkip to conversation

input: ili210x: Fix uninitialized symbols in ili251x_firmware_to_buffer

PATCH In review Purva Yeshi 3 participants 3 messages Apr 19, 2025 – Apr 29, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: ili210x: Fix uninitialized symbols in ili251x_firmware_to_buffer

Fix Smatch-detected issue:

drivers/input/touchscreen/ili210x.c:621 ili251x_firmware_to_buffer()
error: uninitialized symbol 'fw_addr'. drivers/input/touchscreen/ili210x.c:621 ili251x_firmware_to_buffer()
error: uninitialized symbol 'fw_len'.

Initialize 'fw_addr' and 'fw_len' to 0 in ili251x_firmware_to_buffer() to avoid uninitialized use warnings reported by smatch.

Although the while loop ensures both variables are always assigned before use, initializing them silences false positives.

---
 drivers/input/touchscreen/ili210x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/input/touchscreen/ili210x.c +2 -2
index fa38d70aded7..10b52d87c41a 100644
@@ -586,8 +586,8 @@ static const u8 *ili251x_firmware_to_buffer(const struct firmware *fw,
 					    u16 *ac_end, u16 *df_end)
 {
 	const struct ihex_binrec *rec;
-	u32 fw_addr, fw_last_addr = 0;
-	u16 fw_len;
+	u32 fw_addr = 0, fw_last_addr = 0;
+	u16 fw_len = 0;
 
 	/*
 	 * The firmware ihex blob can never be bigger than 64 kiB, so make this
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Purva Yeshi

Fix Smatch-detected issue:

drivers/input/touchscreen/ili210x.c:621 ili251x_firmware_to_buffer()
error: uninitialized symbol 'fw_addr'. drivers/input/touchscreen/ili210x.c:621 ili251x_firmware_to_buffer()
error: uninitialized symbol 'fw_len'.

Quoted 7 lines

Initialize 'fw_addr' and 'fw_len' to 0 in ili251x_firmware_to_buffer() to avoid uninitialized use warnings reported by smatch.

Although the while loop ensures both variables are always assigned before use, initializing them silences false positives.

#2 lore raw
Quoted 11 lines · Oliver Graute
Quoted 10 lines · Purva Yeshi

Fix Smatch-detected issue:

drivers/input/touchscreen/ili210x.c:621 ili251x_firmware_to_buffer()
error: uninitialized symbol 'fw_addr'. drivers/input/touchscreen/ili210x.c:621 ili251x_firmware_to_buffer()
error: uninitialized symbol 'fw_len'.

Initialize 'fw_addr' and 'fw_len' to 0 in ili251x_firmware_to_buffer() to avoid uninitialized use warnings reported by smatch.

Quoted 6 lines
Quoted 4 lines

Although the while loop ensures both variables are always assigned before use, initializing them silences false positives.

No, we will not be adding gratuitous initializations just to appease smatch.

That said, "do {} while (rec);" loop might work better here and also might allow smatch to recognize that both variables are not used uninitialized. I would accept such a patch.

Thanks.

Signature · 1 line
Dmitry