[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20120130125429.56f6f7d0.akpm@linux-foundation.org>
Date: Mon, 30 Jan 2012 12:54:29 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: linux-kernel@...r.kernel.org, Prarit Bhargava <prarit@...hat.com>,
Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <greg@...ah.com>
Subject: Re: [Patch] lkdtm: avoid calling lkdtm_do_action() with spin lock
held
On Sat, 28 Jan 2012 20:52:47 +0800
Cong Wang <xiyou.wangcong@...il.com> wrote:
> lkdtm_do_action() may call sleeping functions like kmalloc(),
> so do not call it with spin lock held.
>
> Cc: Prarit Bhargava <prarit@...hat.com>
> Signed-off-by: WANG Cong <xiyou.wangcong@...il.com>
>
> ---
> diff --git a/drivers/misc/lkdtm.c b/drivers/misc/lkdtm.c
> index 150cd70..28adefe 100644
> --- a/drivers/misc/lkdtm.c
> +++ b/drivers/misc/lkdtm.c
> @@ -354,6 +354,7 @@ 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--;
> @@ -361,10 +362,13 @@ static void lkdtm_handler(void)
> 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)
lkdtm_handler() can be called from module IRQ handlers, so perhaps the
same problems can still happen. The patch does improve things though ;)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists