Commit 7959d556 authored by William Hubbs's avatar William Hubbs Committed by Greg Kroah-Hartman

staging: speakup: fix failure handling

fix the failure handling in kobjects and the main function so that we
release the virtual keyboard if we exit due to another failure.
Signed-off-by: default avatarWilliam Hubbs <w.d.hubbs@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7571f089
...@@ -984,8 +984,10 @@ int speakup_kobj_init(void) ...@@ -984,8 +984,10 @@ int speakup_kobj_init(void)
* not known ahead of time. * not known ahead of time.
*/ */
accessibility_kobj = kobject_create_and_add("accessibility", NULL); accessibility_kobj = kobject_create_and_add("accessibility", NULL);
if (!accessibility_kobj) if (!accessibility_kobj) {
return -ENOMEM; retval = -ENOMEM;
goto out;
}
speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj); speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj);
if (!speakup_kobj) { if (!speakup_kobj) {
...@@ -1002,7 +1004,7 @@ int speakup_kobj_init(void) ...@@ -1002,7 +1004,7 @@ int speakup_kobj_init(void)
if (retval) if (retval)
goto err_group; goto err_group;
return 0; goto out;
err_group: err_group:
sysfs_remove_group(speakup_kobj, &main_attr_group); sysfs_remove_group(speakup_kobj, &main_attr_group);
...@@ -1010,6 +1012,7 @@ int speakup_kobj_init(void) ...@@ -1010,6 +1012,7 @@ int speakup_kobj_init(void)
kobject_put(speakup_kobj); kobject_put(speakup_kobj);
err_acc: err_acc:
kobject_put(accessibility_kobj); kobject_put(accessibility_kobj);
out:
return retval; return retval;
} }
......
...@@ -2253,17 +2253,17 @@ static int __init speakup_init(void) ...@@ -2253,17 +2253,17 @@ static int __init speakup_init(void)
err = speakup_add_virtual_keyboard(); err = speakup_add_virtual_keyboard();
if (err) if (err)
return err; goto out;
initialize_msgs(); /* Initialize arrays for i18n. */ initialize_msgs(); /* Initialize arrays for i18n. */
first_console = kzalloc(sizeof(*first_console), GFP_KERNEL); first_console = kzalloc(sizeof(*first_console), GFP_KERNEL);
if (!first_console) if (!first_console) {
return -ENOMEM; err = -ENOMEM;
err = speakup_kobj_init(); goto err_cons;
if (err) {
kfree(first_console);
return err;
} }
err = speakup_kobj_init();
if (err)
goto err_kobject;
reset_default_chars(); reset_default_chars();
reset_default_chartab(); reset_default_chartab();
...@@ -2299,11 +2299,20 @@ static int __init speakup_init(void) ...@@ -2299,11 +2299,20 @@ static int __init speakup_init(void)
speakup_task = kthread_create(speakup_thread, NULL, "speakup"); speakup_task = kthread_create(speakup_thread, NULL, "speakup");
set_user_nice(speakup_task, 10); set_user_nice(speakup_task, 10);
if (!IS_ERR(speakup_task)) if (IS_ERR(speakup_task)) {
err = -ENOMEM;
goto err_kobject;
}
wake_up_process(speakup_task); wake_up_process(speakup_task);
else goto out;
return -ENOMEM;
return 0; err_kobject:
speakup_kobj_exit();
kfree(first_console);
err_cons:
speakup_remove_virtual_keyboard();
out:
return err;
} }
module_init(speakup_init); module_init(speakup_init);
......
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