Skip to contentSkip to conversation

Input: synaptics - avoid using uninitialized variable when probing

PATCH In review Dmitry Torokhov 3 participants 3 messages Oct 17, 2018 – Oct 19, 2018

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: synaptics - avoid using uninitialized variable when probing

synaptics_detect() does not check whether sending commands to the device succeeds and instead relies on getting unique data from the device. Let's make sure we seed entire buffer with zeroes to make sure we not use garbage on stack that just happen to be 0x47.

---
 drivers/input/mouse/synaptics.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/mouse/synaptics.c +1 -3
index 55d33500d55e..5e85f3cca867 100644
@@ -99,9 +99,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode)
 int synaptics_detect(struct psmouse *psmouse, bool set_properties)
 {
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
-	u8 param[4];
-
-	param[0] = 0;
+	u8 param[4] = { 0 };
 
 	ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
 	ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
Signature · 5 lines
2.19.1.331.ge82ca0e54c-goog


-- 
Dmitry
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dmitry Torokhov

synaptics_detect() does not check whether sending commands to the device succeeds and instead relies on getting unique data from the device. Let's make sure we seed entire buffer with zeroes to make sure we not use garbage on stack that just happen to be 0x47.

---

Cheers,
Benjamin

Quoted 24 lines
 drivers/input/mouse/synaptics.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/mouse/synaptics.c +1 -4
index 55d33500d55e..5e85f3cca867 100644
@@ -99,9 +99,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode)
 int synaptics_detect(struct psmouse *psmouse, bool set_properties)
 {
        struct ps2dev *ps2dev = &psmouse->ps2dev;
-       u8 param[4];
-
-       param[0] = 0;
+       u8 param[4] = { 0 };
 
        ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
        ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
--

2.19.1.331.ge82ca0e54c-goog

--
Dmitry

Reviewed-by on v1 1/1
#2 lore raw
In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

synaptics_detect() does not check whether sending commands to the device succeeds and instead relies on getting unique data from the device. Let's make sure we seed entire buffer with zeroes to make sure we not use garbage on stack that just happen to be 0x47.

doh, was just about to send out the same patch.

Cheers,
Peter

Quoted 25 lines
---
 drivers/input/mouse/synaptics.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/mouse/synaptics.c +1 -3
index 55d33500d55e..5e85f3cca867 100644
@@ -99,9 +99,7 @@ static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode)
 int synaptics_detect(struct psmouse *psmouse, bool set_properties)
 {
 	struct ps2dev *ps2dev = &psmouse->ps2dev;
-	u8 param[4];
-
-	param[0] = 0;
+	u8 param[4] = { 0 };
 
 	ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
 	ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES);
Signature · 5 lines
2.19.1.331.ge82ca0e54c-goog


-- 
Dmitry