Skip to content

Commit

Permalink
lkdtm: avoid calling lkdtm_do_action() with spinlock held
Browse files Browse the repository at this point in the history
lkdtm_do_action() may call sleeping functions like kmalloc(), so do not
call it with spin lock held.

Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
Cc: Prarit Bhargava <prarit@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Cong Wang authored and Linus Torvalds committed Feb 4, 2012
1 parent 99f02ef commit 9261818
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/misc/lkdtm.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,17 +354,21 @@ static void lkdtm_do_action(enum ctype which)
static void lkdtm_handler(void)
{
unsigned long flags;
bool do_it = false;

spin_lock_irqsave(&count_lock, flags);
count--;
printk(KERN_INFO "lkdtm: Crash point %s of type %s hit, trigger in %d rounds\n",
cp_name_to_str(cpoint), cp_type_to_str(cptype), count);

if (count == 0) {
lkdtm_do_action(cptype);
do_it = true;
count = cpoint_count;
}
spin_unlock_irqrestore(&count_lock, flags);

if (do_it)
lkdtm_do_action(cptype);
}

static int lkdtm_register_cpoint(enum cname which)
Expand Down

0 comments on commit 9261818

Please sign in to comment.