aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/analog.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/joystick/analog.c')
-rw-r--r--drivers/input/joystick/analog.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index e9a02db36ecc..7ef68456d7d6 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -434,6 +434,7 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
434{ 434{
435 struct input_dev *input_dev; 435 struct input_dev *input_dev;
436 int i, j, t, v, w, x, y, z; 436 int i, j, t, v, w, x, y, z;
437 int error;
437 438
438 analog_name(analog); 439 analog_name(analog);
439 snprintf(analog->phys, sizeof(analog->phys), 440 snprintf(analog->phys, sizeof(analog->phys),
@@ -505,7 +506,11 @@ static int analog_init_device(struct analog_port *port, struct analog *analog, i
505 506
506 analog_decode(analog, port->axes, port->initial, port->buttons); 507 analog_decode(analog, port->axes, port->initial, port->buttons);
507 508
508 input_register_device(analog->dev); 509 error = input_register_device(analog->dev);
510 if (error) {
511 input_free_device(analog->dev);
512 return error;
513 }
509 514
510 return 0; 515 return 0;
511} 516}
@@ -668,7 +673,8 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
668 return 0; 673 return 0;
669 674
670 fail3: while (--i >= 0) 675 fail3: while (--i >= 0)
671 input_unregister_device(port->analog[i].dev); 676 if (port->analog[i].mask)
677 input_unregister_device(port->analog[i].dev);
672 fail2: gameport_close(gameport); 678 fail2: gameport_close(gameport);
673 fail1: gameport_set_drvdata(gameport, NULL); 679 fail1: gameport_set_drvdata(gameport, NULL);
674 kfree(port); 680 kfree(port);