aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/twidjoy.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:09 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:40:09 -0500
commit127278ce2254c61f1346500374d61e33f74a8729 (patch)
treef7460f3f452d3dbe2d7a52dfa23a51dee0d312f3 /drivers/input/joystick/twidjoy.c
parent52c1f5704d7555a16641429b2e7af5d26d7b119a (diff)
Input: joysticks - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joystick/twidjoy.c')
-rw-r--r--drivers/input/joystick/twidjoy.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index 49085df2d631..3c1c83e8609a 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -194,7 +194,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
194 twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL); 194 twidjoy = kzalloc(sizeof(struct twidjoy), GFP_KERNEL);
195 input_dev = input_allocate_device(); 195 input_dev = input_allocate_device();
196 if (!twidjoy || !input_dev) 196 if (!twidjoy || !input_dev)
197 goto fail; 197 goto fail1;
198 198
199 twidjoy->dev = input_dev; 199 twidjoy->dev = input_dev;
200 snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys); 200 snprintf(twidjoy->phys, sizeof(twidjoy->phys), "%s/input0", serio->phys);
@@ -221,13 +221,17 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
221 221
222 err = serio_open(serio, drv); 222 err = serio_open(serio, drv);
223 if (err) 223 if (err)
224 goto fail; 224 goto fail2;
225
226 err = input_register_device(twidjoy->dev);
227 if (err)
228 goto fail3;
225 229
226 input_register_device(twidjoy->dev);
227 return 0; 230 return 0;
228 231
229 fail: serio_set_drvdata(serio, NULL); 232 fail3: serio_close(serio);
230 input_free_device(input_dev); 233 fail2: serio_set_drvdata(serio, NULL);
234 fail1: input_free_device(input_dev);
231 kfree(twidjoy); 235 kfree(twidjoy);
232 return err; 236 return err;
233} 237}