History

[PATCH] check return value of cpu_callback

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.

Akinobu Mita committed 20 years ago

Commit 07dccf31 parent 6c2d8b54 files · +11 −4Browse files

Showing the changes to kernel/timer.c (1 of 4 files). Show all

Unified · Split

kernel/timer.c+3−1
@@ -1694,8 +1694,10 @@ static struct notifier_block __cpuinitdata timers_nb = { · 1693 unmodified lines
16941694
16951695 void __init init_timers(void)
16961696 {
1697− timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE,
1697+ int err = timer_cpu_notify(&timers_nb, (unsigned long)CPU_UP_PREPARE,
16981698 (void *)(long)smp_processor_id());
1699+
1700+ BUG_ON(err == NOTIFY_BAD);
16991701 register_cpu_notifier(&timers_nb);
17001702 open_softirq(TIMER_SOFTIRQ, run_timer_softirq, NULL);
17011703 }