diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2010-12-16 14:26:58 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-01-10 15:26:10 -0500 |
commit | 7959d55679e4360205c9ebc89d40a5503c53bae2 (patch) | |
tree | b48d85556c24078d6c8dd623ce18bb8f920cbbb0 /drivers/staging | |
parent | 7571f089d7522a95c103558faf313c7af8856ceb (diff) |
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: William Hubbs <w.d.hubbs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/speakup/kobjects.c | 9 | ||||
-rw-r--r-- | drivers/staging/speakup/main.c | 33 |
2 files changed, 27 insertions, 15 deletions
diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index cc79f9edfe9..408bb9b3303 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c | |||
@@ -984,8 +984,10 @@ int speakup_kobj_init(void) | |||
984 | * not known ahead of time. | 984 | * not known ahead of time. |
985 | */ | 985 | */ |
986 | accessibility_kobj = kobject_create_and_add("accessibility", NULL); | 986 | accessibility_kobj = kobject_create_and_add("accessibility", NULL); |
987 | if (!accessibility_kobj) | 987 | if (!accessibility_kobj) { |
988 | return -ENOMEM; | 988 | retval = -ENOMEM; |
989 | goto out; | ||
990 | } | ||
989 | 991 | ||
990 | speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj); | 992 | speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj); |
991 | if (!speakup_kobj) { | 993 | if (!speakup_kobj) { |
@@ -1002,7 +1004,7 @@ int speakup_kobj_init(void) | |||
1002 | if (retval) | 1004 | if (retval) |
1003 | goto err_group; | 1005 | goto err_group; |
1004 | 1006 | ||
1005 | return 0; | 1007 | goto out; |
1006 | 1008 | ||
1007 | err_group: | 1009 | err_group: |
1008 | sysfs_remove_group(speakup_kobj, &main_attr_group); | 1010 | sysfs_remove_group(speakup_kobj, &main_attr_group); |
@@ -1010,6 +1012,7 @@ err_speakup: | |||
1010 | kobject_put(speakup_kobj); | 1012 | kobject_put(speakup_kobj); |
1011 | err_acc: | 1013 | err_acc: |
1012 | kobject_put(accessibility_kobj); | 1014 | kobject_put(accessibility_kobj); |
1015 | out: | ||
1013 | return retval; | 1016 | return retval; |
1014 | } | 1017 | } |
1015 | 1018 | ||
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index 4b7a9c2b965..3cd00396a46 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c | |||
@@ -2253,17 +2253,17 @@ static int __init speakup_init(void) | |||
2253 | 2253 | ||
2254 | err = speakup_add_virtual_keyboard(); | 2254 | err = speakup_add_virtual_keyboard(); |
2255 | if (err) | 2255 | if (err) |
2256 | return err; | 2256 | goto out; |
2257 | 2257 | ||
2258 | initialize_msgs(); /* Initialize arrays for i18n. */ | 2258 | initialize_msgs(); /* Initialize arrays for i18n. */ |
2259 | first_console = kzalloc(sizeof(*first_console), GFP_KERNEL); | 2259 | first_console = kzalloc(sizeof(*first_console), GFP_KERNEL); |
2260 | if (!first_console) | 2260 | if (!first_console) { |
2261 | return -ENOMEM; | 2261 | err = -ENOMEM; |
2262 | err = speakup_kobj_init(); | 2262 | goto err_cons; |
2263 | if (err) { | ||
2264 | kfree(first_console); | ||
2265 | return err; | ||
2266 | } | 2263 | } |
2264 | err = speakup_kobj_init(); | ||
2265 | if (err) | ||
2266 | goto err_kobject; | ||
2267 | 2267 | ||
2268 | reset_default_chars(); | 2268 | reset_default_chars(); |
2269 | reset_default_chartab(); | 2269 | reset_default_chartab(); |
@@ -2299,11 +2299,20 @@ static int __init speakup_init(void) | |||
2299 | 2299 | ||
2300 | speakup_task = kthread_create(speakup_thread, NULL, "speakup"); | 2300 | speakup_task = kthread_create(speakup_thread, NULL, "speakup"); |
2301 | set_user_nice(speakup_task, 10); | 2301 | set_user_nice(speakup_task, 10); |
2302 | if (!IS_ERR(speakup_task)) | 2302 | if (IS_ERR(speakup_task)) { |
2303 | wake_up_process(speakup_task); | 2303 | err = -ENOMEM; |
2304 | else | 2304 | goto err_kobject; |
2305 | return -ENOMEM; | 2305 | } |
2306 | return 0; | 2306 | wake_up_process(speakup_task); |
2307 | goto out; | ||
2308 | |||
2309 | err_kobject: | ||
2310 | speakup_kobj_exit(); | ||
2311 | kfree(first_console); | ||
2312 | err_cons: | ||
2313 | speakup_remove_virtual_keyboard(); | ||
2314 | out: | ||
2315 | return err; | ||
2307 | } | 2316 | } |
2308 | 2317 | ||
2309 | module_init(speakup_init); | 2318 | module_init(speakup_init); |