diff options
| author | Neil Horman <nhorman@tuxdriver.com> | 2006-09-26 02:32:21 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:48:55 -0400 |
| commit | c94a62aae6ebc99b416e55c023b6f5a1d19a400b (patch) | |
| tree | 9176d4e723f6c427afef069b64753e1b1141afdb | |
| parent | 3a750363e6075a28e5542ce93a69c620c0cfd605 (diff) | |
[PATCH] apm: clean up module initalization
Clean up module initalization for apm.c. I had started by auditing for
proper return code checks in misc_register, but I found that in the event
of an initalization failure, a proc file and a kernel thread were left
hanging out. this patch properly cleans up those loose ends on any
initalization failure.
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | arch/i386/kernel/apm.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 8591f2fa920c..24fd577861f1 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c | |||
| @@ -2339,6 +2339,7 @@ static int __init apm_init(void) | |||
| 2339 | ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD); | 2339 | ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD); |
| 2340 | if (ret < 0) { | 2340 | if (ret < 0) { |
| 2341 | printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n"); | 2341 | printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n"); |
| 2342 | remove_proc_entry("apm", NULL); | ||
| 2342 | return -ENOMEM; | 2343 | return -ENOMEM; |
| 2343 | } | 2344 | } |
| 2344 | 2345 | ||
| @@ -2348,7 +2349,13 @@ static int __init apm_init(void) | |||
| 2348 | return 0; | 2349 | return 0; |
| 2349 | } | 2350 | } |
| 2350 | 2351 | ||
| 2351 | misc_register(&apm_device); | 2352 | /* |
| 2353 | * Note we don't actually care if the misc_device cannot be registered. | ||
| 2354 | * this driver can do its job without it, even if userspace can't | ||
| 2355 | * control it. just log the error | ||
| 2356 | */ | ||
| 2357 | if (misc_register(&apm_device)) | ||
| 2358 | printk(KERN_WARNING "apm: Could not register misc device.\n"); | ||
| 2352 | 2359 | ||
| 2353 | if (HZ != 100) | 2360 | if (HZ != 100) |
| 2354 | idle_period = (idle_period * HZ) / 100; | 2361 | idle_period = (idle_period * HZ) / 100; |
