projects/linux·commit 09dc3cf9

printk: avoid double lock acquire

09dc3cf9 · Peter Zijlstra <[email protected]> · 2011-12-08 14:34:13 -08:00

Commit 4f2a8d3cf5e ("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]>
Commit
09dc3cf93f7d16fdd37a0ad8486faebb5e2769ec
Parents
c193c82f

Changes

1 files changed · +2 −1

FileStatusAddDelContent
kernel/printk.cmodified+2−1View file

kernel/printk.c

View file
diff --git a/kernel/printk.c b/kernel/printk.c
index 1455a0d..7982a0a 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1293,10 +1293,11 @@ again:
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();
}