Skip to contentSkip to conversation

hynitron_cstxxx: Initialize tmp to 0 to fix uninitialized variable issue

PATCH Applied Chris Morgan 2 participants 2 messages Nov 17, 2022 – Nov 18, 2022

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

PATCH 1/1 hynitron_cstxxx: Initialize tmp to 0 to fix uninitialized variable issue

From: Chris Morgan <[email protected]>

In the very unlikely event the cst3xx_i2c_write() fails inside of the cst3xx_bootloader_enter() function 5 times in a row, the uninitalized value of tmp will get compared to CST3XX_BOOTLDR_CHK_VAL. Initialize the value of tmp to 0 so that in this unlikely event we are comparing 0 instead of an uninitalized variable.

Fixes 66603243f528 ("Input: add driver for Hynitron cstxxx touchscreens")
---
 drivers/input/touchscreen/hynitron_cstxxx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/hynitron_cstxxx.c +1 -1
index 333439fedb90..ed9056da786d 100644
@@ -208,7 +208,7 @@ static int cst3xx_bootloader_enter(struct i2c_client *client)
 {
 	int ret;
 	u8 retry;
-	u32 tmp;
+	u32 tmp = 0;
 	unsigned char buf[3];
 
 	for (retry = 0; retry < 5; retry++) {
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Chris Morgan

From: Chris Morgan <[email protected]>

In the very unlikely event the cst3xx_i2c_write() fails inside of the cst3xx_bootloader_enter() function 5 times in a row, the uninitalized value of tmp will get compared to CST3XX_BOOTLDR_CHK_VAL. Initialize the value of tmp to 0 so that in this unlikely event we are comparing 0 instead of an uninitalized variable.

Quoted 4 lines
Fixes 66603243f528 ("Input: add driver for Hynitron cstxxx touchscreens")

Applied, thank you.

Signature · 1 line
Dmitry