]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
printk: avoid double lock acquire
authorPeter Zijlstra <peterz@infradead.org>
Fri, 2 Dec 2011 03:06:49 +0000 (14:06 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 6 Dec 2011 03:51:00 +0000 (14:51 +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 dfd8f73dcb7656fbe6e4daf6c2d341b439056ed3..187662f29aaf97965cf862f94f3c885b02cb9549 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();
 }