[PATCH] 12/18 console_unblank bug fix

Arnd Bergmann
2002-08-05T16:09:21Z

Problem: console_unblank can cause an endless trap loop if the console
semaphore is already taken and console_unblank is called in
interrupt context.
Solution: To avoid the trap loop just try to take the console semaphore
with down_trylock and exit if it fails. It is not perfect
since c->unblank() is not called in this case but way better
than an endless trap loop. s390/s390x are the only two
architectures that still use console_unblank. This patch
has been accepted to 2.5.

diff -urN linux-2.4.19-rc3/kernel/printk.c linux-2.4.19-s390/kernel/printk.c
--- linux-2.4.19-rc3/kernel/printk.c Tue Jul 30 09:02:32 2002
+++ linux-2.4.19-s390/kernel/printk.c Tue Jul 30 09:02:57 2002
@@ -556,7 +556,14 @@
{
struct console *c;

- acquire_console_sem();
+ /*
+ * Try to get the console semaphore. If someone else owns it
+ * we have to return without unblanking because console_unblank
+ * may be called in interrupt context.
+ */
+ if (down_trylock(&console_sem) != 0)
+ return;
+ console_may_schedule = 0;
for (c = console_drivers; c != NULL; c = c->next)
if ((c->flags & CON_ENABLED) && c->unblank)
c->unblank();