Skip to contentSkip to conversation

Input: psmouse - fix psmouse detect function is a NULL pointer

PATCH In review Qiang Ma 2 participants 2 messages May 19, 2021 – Jun 2, 2021

Subsystems (2)
lore
Share & tools
lore

Qiang Ma

author
#0 lore raw

PATCH 1/1 Input: psmouse - fix psmouse detect function is a NULL pointer

Add a check for psmouse_do_detect(), when the detect is NULL pointer, returning false, avoiding this possible NULL pointer exception.

---
 drivers/input/mouse/psmouse-base.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/input/mouse/psmouse-base.c +3 -0
index 0b4a3039f312..86b095728587 100644
@@ -1006,6 +1006,9 @@ static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool),
 	if (set_properties)
 		psmouse_apply_defaults(psmouse);
 
+	if (!detect)
+		return false;
+
 	return detect(psmouse, set_properties) == 0;
 }
 
Signature · 1 line
2.20.1
maintainer
#1 lore raw

Hi Qiang,

Quoted 13 lines · Qiang Ma

Add a check for psmouse_do_detect(), when the detect is NULL pointer, returning false, avoiding this possible NULL pointer exception.

---
 drivers/input/mouse/psmouse-base.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/input/mouse/psmouse-base.c +0 -0
index 0b4a3039f312..86b095728587 100644

drivers/input/mouse/psmouse-base.c static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool), · line 1010

Quoted 5 lines
drivers/input/mouse/psmouse-base.c +2 -0
@@ -1006,6 +1006,9 @@ static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool),
 	if (set_properties)
 		psmouse_apply_defaults(psmouse);
 
+	if (!detect)
+		return false;

There are no protocols that do not define detect() method, so this condition is not possible.

drivers/input/mouse/psmouse-base.c static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool), · line 1014

Quoted 4 lines
drivers/input/mouse/psmouse-base.c +1 -0
+
 	return detect(psmouse, set_properties) == 0;
 }
 

Thanks.

Signature · 1 line
Dmitry