From d27cb6f4a57d7244fccce946523b1904758f948e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Thu, 20 Feb 2014 19:39:44 +0800 Subject: [PATCH] rk: proc: fix slub warning when call setup_irq BUG: sleeping function called from invalid context at mm/slub.c:926 in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/3 INFO: lockdep is turned off. irq event stamp: 45900 hardirqs last enabled at (45899): [] rcu_preempt_note_context_switch+0x174/0x18c hardirqs last disabled at (45900): [] _raw_spin_lock_irq+0x18/0x50 softirqs last enabled at (45744): [] irq_enter+0x50/0x78 softirqs last disabled at (45743): [] irq_enter+0x44/0x78 CPU: 3 PID: 0 Comm: swapper/3 Tainted: G O 3.10.0 #405 [] (unwind_backtrace+0x0/0xe0) from [] (show_stack+0x10/0x14) [] (show_stack+0x10/0x14) from [] (__kmalloc+0x70/0x228) [] (__kmalloc+0x70/0x228) from [] (__proc_create+0x94/0xf0) [] (__proc_create+0x94/0xf0) from [] (proc_mkdir_data+0x30/0x74) [] (proc_mkdir_data+0x30/0x74) from [] (register_handler_proc+0xe8/0x114) [] (register_handler_proc+0xe8/0x114) from [] (__setup_irq+0x334/0x3fc) [] (__setup_irq+0x334/0x3fc) from [] (setup_irq+0x58/0x80) [] (setup_irq+0x58/0x80) from [] (rk_timer_init_clockevent+0x98/0xcc) [] (rk_timer_init_clockevent+0x98/0xcc) from [] (percpu_timer_setup+0x54/0xa8) [] (percpu_timer_setup+0x54/0xa8) from [] (secondary_start_kernel+0x128/0x160) [] (secondary_start_kernel+0x128/0x160) from [<600081bc>] (0x600081bc) --- fs/proc/generic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index a2596afffae6..7adb3272a3e7 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -8,6 +8,7 @@ * Copyright (C) 1997 Theodore Ts'o */ +#include #include #include #include @@ -134,7 +135,7 @@ int proc_alloc_inum(unsigned int *inum) int error; retry: - if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL)) + if (!ida_pre_get(&proc_inum_ida, (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL)) return -ENOMEM; spin_lock_irq(&proc_inum_lock); @@ -387,7 +388,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent, len = strlen(fn); - ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, GFP_KERNEL); + ent = kzalloc(sizeof(struct proc_dir_entry) + len + 1, (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL); if (!ent) goto out; -- 2.34.1