LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] printk: clean up recursion check related static variables
Date: Thu, 14 Feb 2008 10:39:04 +0900	[thread overview]
Message-ID: <47B39BB8.5030703@gmail.com> (raw)
In-Reply-To: <47B38718.4030509@gmail.com>

Make printk_recursion_bug_msg static, drop printk prefix from recurson
variables and move them into vprintk().

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
This is slightly modified version of the clean up part.  I don't think
it's wise to pull out all static variables out of functions.  Thanks.

 kernel/printk.c |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Index: work/kernel/printk.c
===================================================================
--- work.orig/kernel/printk.c
+++ work/kernel/printk.c
@@ -613,15 +613,13 @@ asmlinkage int printk(const char *fmt, .
 	return r;
 }
 
-/* cpu currently holding logbuf_lock */
-static volatile unsigned int printk_cpu = UINT_MAX;
-
-const char printk_recursion_bug_msg [] =
-			KERN_CRIT "BUG: recent printk recursion!\n";
-static int printk_recursion_bug;
-
 asmlinkage int vprintk(const char *fmt, va_list args)
 {
+	/* cpu currently holding logbuf_lock */
+	static volatile unsigned int printk_cpu = UINT_MAX;
+	static const char recursion_bug_msg [] =
+		KERN_CRIT "BUG: recent printk recursion!\n";
+	static int recursion_bug;
 	static int log_level_unknown = 1;
 	static char printk_buf[1024];
 
@@ -649,7 +647,7 @@ asmlinkage int vprintk(const char *fmt, 
 		 * it can be printed at the next appropriate moment:
 		 */
 		if (!oops_in_progress) {
-			printk_recursion_bug = 1;
+			recursion_bug = 1;
 			goto out_restore_irqs;
 		}
 		zap_locks();
@@ -659,10 +657,10 @@ asmlinkage int vprintk(const char *fmt, 
 	spin_lock(&logbuf_lock);
 	printk_cpu = this_cpu;
 
-	if (printk_recursion_bug) {
-		printk_recursion_bug = 0;
-		strcpy(printk_buf, printk_recursion_bug_msg);
-		printed_len = sizeof(printk_recursion_bug_msg);
+	if (recursion_bug) {
+		recursion_bug = 0;
+		strcpy(printk_buf, recursion_bug_msg);
+		printed_len = sizeof(recursion_bug_msg);
 	}
 	/* Emit the output into the temporary buffer */
 	printed_len += vscnprintf(printk_buf + printed_len,

      parent reply	other threads:[~2008-02-14  1:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-13  8:46 [PATCH REPOST] printk: fix possible printk buffer overrun introduced with recursion check Tejun Heo
2008-02-13 12:45 ` Ingo Molnar
2008-02-14  0:11   ` Tejun Heo
2008-02-14  1:32     ` [PATCH UPDATED] " Tejun Heo
2008-02-14  1:39     ` Tejun Heo [this message]

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=47B39BB8.5030703@gmail.com \
    --to=htejun@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=randy.dunlap@oracle.com \
    --cc=torvalds@linux-foundation.org \
    --subject='Re: [PATCH] printk: clean up recursion check related static variables' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).