Skip to contentSkip to conversation

Input: ALPS - fix memory leak when detection fails

PATCH In review Dmitry Torokhov 2 participants 2 messages Feb 27, 2015 – Feb 28, 2015

Subsystems (3)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/1 Input: ALPS - fix memory leak when detection fails

This fixes memory leak introduced by commit
a09221e83e13e09a33109b9b037484eade901cea

---
 drivers/input/mouse/alps.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/input/mouse/alps.c +3 -1
index d28726a..1bd15eb 100644
@@ -2605,8 +2605,10 @@ int alps_detect(struct psmouse *psmouse, bool set_properties)
 		return -ENOMEM;
 
 	error = alps_identify(psmouse, priv);
-	if (error)
+	if (error) {
+		kfree(priv);
 		return error;
+	}
 
 	if (set_properties) {
 		psmouse->vendor = "ALPS";
Signature · 5 lines
2.2.0.rc0.207.ga3a616c


-- 
Dmitry
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · On Saturday 28 February 2015 00:53:57 Dmitry Torokhov wrote:

This fixes memory leak introduced by commit
a09221e83e13e09a33109b9b037484eade901cea

---
 drivers/input/mouse/alps.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/input/mouse/alps.c index d28726a..1bd15eb 100644

drivers/input/mouse/alps.c +0 -0
@@ -2605,8 +2605,10 @@ int alps_detect(struct psmouse
 *psmouse, bool set_properties) return -ENOMEM;

drivers/input/mouse/alps.c int alps_detect(struct psmouse · line 2614

Quoted 10 lines
drivers/input/mouse/alps.c +3 -1
 
 	error = alps_identify(psmouse, priv);
-	if (error)
+	if (error) {
+		kfree(priv);
 		return error;
+	}
 
 	if (set_properties) {
 		psmouse->vendor = "ALPS";
Signature · 2 lines
Pali Rohár
[email protected]