Skip to contentSkip to conversation

fix NULL pointer deference in ALPS

PATCH In review Benoit Boissinot 3 participants 5 messages Mar 7, 2005

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

PATCH 1/1 fix NULL pointer deference in ALPS

I get a NULL pointer deference in with alps while suspending.

The following patch fixes it: alps_get_model returns a pointer or NULL in case of errors, so we need to check for the results being NULL, not negative.

Since it is trivial, it is maybe a candidate for 2.6.11.2.

It does not apply to -mm since the last occurence of alps_get_model was corrected (but not the others), if needed i can send a patch for -mm as well.

regards,

Benoit

drivers/input/mouse/alps.c +3 -3
@@ -325,7 +325,7 @@ static int alps_reconnect(struct psmouse
 	int model;
 	unsigned char param[4];
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if (!(model = alps_get_model(psmouse)))
 		return -1;
 
 	if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
@@ -358,7 +358,7 @@ int alps_init(struct psmouse *psmouse)
 	unsigned char param[4];
 	int model;
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if (!(model = alps_get_model(psmouse)))
 		return -1;
 
 	printk(KERN_INFO "ALPS Touchpad (%s) detected\n",
@@ -412,7 +412,7 @@ int alps_init(struct psmouse *psmouse)
 
 int alps_detect(struct psmouse *psmouse, int set_properties)
 {
-	if (alps_get_model(psmouse) < 0)
+	if (!alps_get_model(psmouse))
 		return -1;
 
 	if (set_properties) {
#1 lore raw
Quoted 2 lines · Benoit Boissinot

alps_get_model returns a pointer or NULL in case of errors, so we need to check for the results being NULL, not negative.

2.6.11-bk2: int alps_get_model(struct psmouse *psmouse)
takes 1 argument, returns -1 on error

2.6.11-mm1: static struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
takes 2 arguments, returns NULL on error

drivers/input/mouse/alps.c

Quoted 11 lines
drivers/input/mouse/alps.c +3 -3
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if (!(model = alps_get_model(psmouse)))
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if (!(model = alps_get_model(psmouse)))
 
-	if (alps_get_model(psmouse) < 0)
+	if (!alps_get_model(psmouse))

To what version of kernel this patch should be applied?

Alexey

#2 lore raw
Quoted 11 lines · Alexey Dobriyan
Quoted 2 lines · Benoit Boissinot

alps_get_model returns a pointer or NULL in case of errors, so we need to check for the results being NULL, not negative.

2.6.11-bk2: int alps_get_model(struct psmouse *psmouse)
takes 1 argument, returns -1 on error

2.6.11-mm1: static struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
takes 2 arguments, returns NULL on error

Sorry, i misreaded the vanilla code, it only applies to -mm.

Since it seems to be fixed in bk-input, please forget the patch.

Sorry.

Benoit

Signature · 1 line
powered by bash/screen/(urxvt/fvwm|linux-console)/gentoo/gnu/linux OS
#3 lore raw
In reply to Benoit Boissinot
Quoted 11 lines · Benoit Boissinot

I get a NULL pointer deference in with alps while suspending.

The following patch fixes it: alps_get_model returns a pointer or NULL in case of errors, so we need to check for the results being NULL, not negative.

Since it is trivial, it is maybe a candidate for 2.6.11.2.

It does not apply to -mm since the last occurence of alps_get_model was corrected (but not the others), if needed i can send a patch for -mm as well.

I already fixed it in my tree, but feel free to push it for the sucker tree.

Quoted 38 lines

regards,

Benoit

drivers/input/mouse/alps.c +3 -3
@@ -325,7 +325,7 @@ static int alps_reconnect(struct psmouse
 	int model;
 	unsigned char param[4];
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if (!(model = alps_get_model(psmouse)))
 		return -1;
 
 	if (model == ALPS_MODEL_DUALPOINT && alps_passthrough_mode(psmouse, 1))
@@ -358,7 +358,7 @@ int alps_init(struct psmouse *psmouse)
 	unsigned char param[4];
 	int model;
 
-	if ((model = alps_get_model(psmouse)) < 0)
+	if (!(model = alps_get_model(psmouse)))
 		return -1;
 
 	printk(KERN_INFO "ALPS Touchpad (%s) detected\n",
@@ -412,7 +412,7 @@ int alps_init(struct psmouse *psmouse)
 
 int alps_detect(struct psmouse *psmouse, int set_properties)
 {
-	if (alps_get_model(psmouse) < 0)
+	if (!alps_get_model(psmouse))
 		return -1;
 
 	if (set_properties) {
Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR
#4 lore raw
Quoted 7 lines · Vojtech Pavlik
Quoted 6 lines · Benoit Boissinot

I get a NULL pointer deference in with alps while suspending.

The following patch fixes it: alps_get_model returns a pointer or NULL in case of errors, so we need to check for the results being NULL, not negative.

Quoted 8 lines
Quoted 5 lines

Since it is trivial, it is maybe a candidate for 2.6.11.2.

It does not apply to -mm since the last occurence of alps_get_model was corrected (but not the others), if needed i can send a patch for -mm as well.

I already fixed it in my tree, but feel free to push it for the sucker tree.

Oops. No, 2.6.11 doesn't need that fix. Only -mm does, and it's already queued.

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR