Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: ALPS - handle errors from input_register_device()

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+9 -5
+9 -4
drivers/input/mouse/alps.c
··· 424 424 struct input_dev *dev1 = psmouse->dev, *dev2; 425 425 int version; 426 426 427 - psmouse->private = priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); 427 + priv = kzalloc(sizeof(struct alps_data), GFP_KERNEL); 428 428 dev2 = input_allocate_device(); 429 429 if (!priv || !dev2) 430 430 goto init_fail; 431 431 432 432 priv->dev2 = dev2; 433 433 434 - if (!(priv->i = alps_get_model(psmouse, &version))) 434 + priv->i = alps_get_model(psmouse, &version); 435 + if (!priv->i) 435 436 goto init_fail; 436 437 437 438 if ((priv->i->flags & ALPS_PASS) && alps_passthrough_mode(psmouse, 1)) ··· 481 480 dev2->relbit[LONG(REL_X)] |= BIT(REL_X) | BIT(REL_Y); 482 481 dev2->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT); 483 482 484 - input_register_device(priv->dev2); 483 + if (input_register_device(priv->dev2)) 484 + goto init_fail; 485 485 486 486 psmouse->protocol_handler = alps_process_byte; 487 487 psmouse->poll = alps_poll; ··· 493 491 /* We are having trouble resyncing ALPS touchpads so disable it for now */ 494 492 psmouse->resync_time = 0; 495 493 494 + psmouse->private = priv; 496 495 return 0; 497 496 498 497 init_fail: 498 + psmouse_reset(psmouse); 499 499 input_free_device(dev2); 500 500 kfree(priv); 501 501 return -1; ··· 508 504 int version; 509 505 const struct alps_model_info *model; 510 506 511 - if (!(model = alps_get_model(psmouse, &version))) 507 + model = alps_get_model(psmouse, &version); 508 + if (!model) 512 509 return -1; 513 510 514 511 if (set_properties) {
-1
drivers/input/mouse/alps.h
··· 20 20 21 21 struct alps_data { 22 22 struct input_dev *dev2; /* Relative device */ 23 - char name[32]; /* Name */ 24 23 char phys[32]; /* Phys */ 25 24 const struct alps_model_info *i;/* Info */ 26 25 int prev_fin; /* Finger bit from previous packet */