Skip to content

Commit

Permalink
gcc-4.6: printk: use stable variable to dump kmsg buffer
Browse files Browse the repository at this point in the history
kmsg_dump takes care to sample the global variables
inside a spinlock, but then goes on to use the same
variables outside the spinlock region too.

Use the correct variable. This will make the race
window smaller.

Found by gcc 4.6's new warnings.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Aug 10, 2010
1 parent 547415d commit 8c4af38
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1549,18 +1549,18 @@ void kmsg_dump(enum kmsg_dump_reason reason)
chars = logged_chars;
spin_unlock_irqrestore(&logbuf_lock, flags);

if (logged_chars > end) {
s1 = log_buf + log_buf_len - logged_chars + end;
l1 = logged_chars - end;
if (chars > end) {
s1 = log_buf + log_buf_len - chars + end;
l1 = chars - end;

s2 = log_buf;
l2 = end;
} else {
s1 = "";
l1 = 0;

s2 = log_buf + end - logged_chars;
l2 = logged_chars;
s2 = log_buf + end - chars;
l2 = chars;
}

if (!spin_trylock_irqsave(&dump_list_lock, flags)) {
Expand Down

0 comments on commit 8c4af38

Please sign in to comment.