From: Akinobu Mita <mita@miraclelinux.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] check return value of cpu_callback
Date: Sun, 13 Aug 2006 18:18:10 +0800 [thread overview]
Message-ID: <20060813101810.GC8703@miraclelinux.com> (raw)
Spawing ksoftirqd, migration, or watchdog, and calling init_timers_cpu() may
fail with small memory. If it happens in initcalls, kernel NULL pointer
dereference happens later. This patch makes crash happen immediately in
such cases. It seems a bit better than getting kernel NULL pointer
dereference later.
CC: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
kernel/sched.c | 4 +++-
kernel/softirq.c | 4 +++-
kernel/softlockup.c | 3 ++-
kernel/timer.c | 4 +++-
4 files changed, 11 insertions(+), 4 deletions(-)
Index: work-failmalloc/kernel/softirq.c
===================================================================
--- work-failmalloc.orig/kernel/softirq.c
+++ work-failmalloc/kernel/softirq.c
@@ -612,7 +612,9 @@ static struct notifier_block __cpuinitda
__init int spawn_ksoftirqd(void)
{
void *cpu = (void *)(long)smp_processor_id();
- cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
+ int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
+
+ BUG_ON(err == NOTIFY_BAD);
cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
register_cpu_notifier(&cpu_nfb);
return 0;
Index: work-failmalloc/kernel/softlockup.c
===================================================================
--- work-failmalloc.orig/kernel/softlockup.c
+++ work-failmalloc/kernel/softlockup.c
@@ -149,8 +149,9 @@ static struct notifier_block __cpuinitda
__init void spawn_softlockup_task(void)
{
void *cpu = (void *)(long)smp_processor_id();
+ int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
- cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu);
+ BUG_ON(err == NOTIFY_BAD);
cpu_callback(&cpu_nfb, CPU_ONLINE, cpu);
register_cpu_notifier(&cpu_nfb);
Index: work-failmalloc/kernel/sched.c
===================================================================
--- work-failmalloc.orig/kernel/sched.c
+++ work-failmalloc/kernel/sched.c
@@ -5237,9 +5237,11 @@ static struct notifier_block __cpuinitda
int __init migration_init(void)
{
void *cpu = (void *)(long)smp_processor_id();
+ int err;
/* Start one for the boot CPU: */
- migration_call(&migration_notifier, CPU_UP_PREPARE, cpu);
+ err = migration_call(&migration_notifier, CPU_UP_PREPARE, cpu);
+ BUG_ON(err == NOTIFY_BAD);
migration_call(&migration_notifier, CPU_ONLINE, cpu);
register_cpu_notifier(&migration_notifier);
Index: work-failmalloc/kernel/timer.c
===================================================================
--- work-failmalloc.orig/kernel/timer.c
+++ work-failmalloc/kernel/timer.c
@@ -1715,8 +1715,10 @@ static struct notifier_block __cpuinitda
void __init init_timers(void)
{
- timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE,
+ int err = timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE,
(void *)(long)smp_processor_id());
+
+ BUG_ON(err == NOTIFY_BAD);
register_cpu_notifier(&timers_nb);
open_softirq(TIMER_SOFTIRQ, run_timer_softirq, NULL);
}
reply other threads:[~2006-08-13 10:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20060813101810.GC8703@miraclelinux.com \
--to=mita@miraclelinux.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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