Commit ab52cd66 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: turbografx - handle errors from input_register_device()

Also tgfx_remove shouldn't be marked __exit as it is also called from
__init code.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 77fc46ca
...@@ -204,14 +204,14 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) ...@@ -204,14 +204,14 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
if (n_buttons[i] > 6) { if (n_buttons[i] > 6) {
printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]); printk(KERN_ERR "turbografx.c: Invalid number of buttons %d\n", n_buttons[i]);
err = -EINVAL; err = -EINVAL;
goto err_free_devs; goto err_unreg_devs;
} }
tgfx->dev[i] = input_dev = input_allocate_device(); tgfx->dev[i] = input_dev = input_allocate_device();
if (!input_dev) { if (!input_dev) {
printk(KERN_ERR "turbografx.c: Not enough memory for input device\n"); printk(KERN_ERR "turbografx.c: Not enough memory for input device\n");
err = -ENOMEM; err = -ENOMEM;
goto err_free_devs; goto err_unreg_devs;
} }
tgfx->sticks |= (1 << i); tgfx->sticks |= (1 << i);
...@@ -238,7 +238,9 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) ...@@ -238,7 +238,9 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
for (j = 0; j < n_buttons[i]; j++) for (j = 0; j < n_buttons[i]; j++)
set_bit(tgfx_buttons[j], input_dev->keybit); set_bit(tgfx_buttons[j], input_dev->keybit);
input_register_device(tgfx->dev[i]); err = input_register_device(tgfx->dev[i]);
if (err)
goto err_free_dev;
} }
if (!tgfx->sticks) { if (!tgfx->sticks) {
...@@ -249,8 +251,11 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) ...@@ -249,8 +251,11 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
return tgfx; return tgfx;
err_free_devs: err_free_dev:
input_free_device(tgfx->dev[i]);
err_unreg_devs:
while (--i >= 0) while (--i >= 0)
if (tgfx->dev[i])
input_unregister_device(tgfx->dev[i]); input_unregister_device(tgfx->dev[i]);
err_free_tgfx: err_free_tgfx:
kfree(tgfx); kfree(tgfx);
...@@ -262,7 +267,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) ...@@ -262,7 +267,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs)
return ERR_PTR(err); return ERR_PTR(err);
} }
static void __exit tgfx_remove(struct tgfx *tgfx) static void tgfx_remove(struct tgfx *tgfx)
{ {
int i; int i;
...@@ -300,6 +305,7 @@ static int __init tgfx_init(void) ...@@ -300,6 +305,7 @@ static int __init tgfx_init(void)
if (err) { if (err) {
while (--i >= 0) while (--i >= 0)
if (tgfx_base[i])
tgfx_remove(tgfx_base[i]); tgfx_remove(tgfx_base[i]);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment