diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:39:56 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-11-05 22:39:56 -0500 |
commit | 2b03b60e6b8635fffdd15d5d24943950f2bbf96e (patch) | |
tree | 17f0354b7edb08920a89e663ef724c84518c49fa /drivers/input/keyboard/sunkbd.c | |
parent | 41ad5fbabda0c3930136bb40cfc7a0c23013365f (diff) |
Input: keyboards - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/sunkbd.c')
-rw-r--r-- | drivers/input/keyboard/sunkbd.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index cac4781103c3..d1b62f77a716 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -243,7 +243,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
243 | sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); | 243 | sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); |
244 | input_dev = input_allocate_device(); | 244 | input_dev = input_allocate_device(); |
245 | if (!sunkbd || !input_dev) | 245 | if (!sunkbd || !input_dev) |
246 | goto fail; | 246 | goto fail1; |
247 | 247 | ||
248 | sunkbd->serio = serio; | 248 | sunkbd->serio = serio; |
249 | sunkbd->dev = input_dev; | 249 | sunkbd->dev = input_dev; |
@@ -255,11 +255,11 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
255 | 255 | ||
256 | err = serio_open(serio, drv); | 256 | err = serio_open(serio, drv); |
257 | if (err) | 257 | if (err) |
258 | goto fail; | 258 | goto fail2; |
259 | 259 | ||
260 | if (sunkbd_initialize(sunkbd) < 0) { | 260 | if (sunkbd_initialize(sunkbd) < 0) { |
261 | serio_close(serio); | 261 | err = -ENODEV; |
262 | goto fail; | 262 | goto fail3; |
263 | } | 263 | } |
264 | 264 | ||
265 | snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); | 265 | snprintf(sunkbd->name, sizeof(sunkbd->name), "Sun Type %d keyboard", sunkbd->type); |
@@ -287,11 +287,17 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
287 | clear_bit(0, input_dev->keybit); | 287 | clear_bit(0, input_dev->keybit); |
288 | 288 | ||
289 | sunkbd_enable(sunkbd, 1); | 289 | sunkbd_enable(sunkbd, 1); |
290 | input_register_device(sunkbd->dev); | 290 | |
291 | err = input_register_device(sunkbd->dev); | ||
292 | if (err) | ||
293 | goto fail4; | ||
294 | |||
291 | return 0; | 295 | return 0; |
292 | 296 | ||
293 | fail: serio_set_drvdata(serio, NULL); | 297 | fail4: sunkbd_enable(sunkbd, 0); |
294 | input_free_device(input_dev); | 298 | fail3: serio_close(serio); |
299 | fail2: serio_set_drvdata(serio, NULL); | ||
300 | fail1: input_free_device(input_dev); | ||
295 | kfree(sunkbd); | 301 | kfree(sunkbd); |
296 | return err; | 302 | return err; |
297 | } | 303 | } |