Skip to content

Commit

Permalink
printk: avoid double lock acquire
Browse files Browse the repository at this point in the history
Commit 4f2a8d3 ("printk: Fix console_sem vs logbuf_lock unlock race")
introduced another silly bug where we would want to acquire an already
held lock.  Avoid this.

Reported-by: Andrea Arcangeli <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Peter Zijlstra authored and torvalds committed Dec 9, 2011
1 parent c193c82 commit 09dc3cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,10 +1293,11 @@ void console_unlock(void)
raw_spin_lock(&logbuf_lock);
if (con_start != log_end)
retry = 1;
raw_spin_unlock_irqrestore(&logbuf_lock, flags);

if (retry && console_trylock())
goto again;

raw_spin_unlock_irqrestore(&logbuf_lock, flags);
if (wake_klogd)
wake_up_klogd();
}
Expand Down

0 comments on commit 09dc3cf

Please sign in to comment.