From: Neil Horman <nhorman@tuxdriver.com>
To: kernel-janitors@lists.osdl.org
Cc: linux-laptop@vger.kernel.org, akpm@osdl.org,
sfr@canb.auug.org.au, nhorman@tuxdriver.com
Subject: [KJ] [PATCH] apm: clean up module initalization
Date: Tue, 1 Aug 2006 12:25:48 -0400 [thread overview]
Message-ID: <20060801162548.GA11605@localhost.localdomain> (raw)
Patch to 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.
Regards
Neil
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
apm.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 8591f2f..75d8bde 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -2339,16 +2339,22 @@ #endif
ret = kernel_thread(apm, NULL, CLONE_KERNEL | SIGCHLD);
if (ret < 0) {
printk(KERN_ERR "apm: disabled - Unable to start kernel thread.\n");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto out_proc;
}
if (num_online_cpus() > 1 && !smp ) {
printk(KERN_NOTICE
"apm: disabled - APM is not SMP safe (power off active).\n");
- return 0;
+ ret = -EOPNOTSUPP;
+ goto out_thread;
}
- misc_register(&apm_device);
+ if (misc_register(&apm_device)) {
+ printk(KERN_ERR "apm: Unable to register misc device\n");
+ ret = -ENOMEM;
+ goto out_thread;
+ }
if (HZ != 100)
idle_period = (idle_period * HZ) / 100;
@@ -2357,8 +2363,17 @@ #endif
pm_idle = apm_cpu_idle;
set_pm_idle = 1;
}
+
+ return 0;
- return 0;
+out_thread:
+ exit_kapmd = 1;
+ while (kapmd_running)
+ schedule();
+out_proc:
+ remove_proc_entry("apm", NULL);
+
+ return ret;
}
static void __exit apm_exit(void)
next reply other threads:[~2006-08-01 16:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-01 16:25 Neil Horman [this message]
2006-08-01 21:45 ` [KJ] [PATCH] apm: clean up module initalization Alexey Dobriyan
2006-08-02 1:04 ` Stephen Rothwell
2006-08-02 2:21 ` Neil Horman
2006-08-02 3:54 ` Stephen Rothwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060801162548.GA11605@localhost.localdomain \
--to=nhorman@tuxdriver.com \
--cc=akpm@osdl.org \
--cc=kernel-janitors@lists.osdl.org \
--cc=linux-laptop@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox