]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
printk: avoid double lock acquire
authorPeter Zijlstra <peterz@infradead.org>
Thu, 8 Dec 2011 04:32:02 +0000 (15:32 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 9 Dec 2011 04:52:18 +0000 (15:52 +1100)
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 <aarcange@redhat.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/printk.c

index ecdf6816b64438bfd3a51a2c726ece582ae088d7..989e4a52da76e10c6bb43601d1a49931f7bb82ed 100644 (file)
@@ -1292,10 +1292,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();
 }