Commit 19fa6e60 authored by Denis Kirjanov's avatar Denis Kirjanov Committed by Greg Kroah-Hartman

tty/hvc_console: fix console lock ordering with spinlock

hvc_remove() takes a spin lock first then acquires the console
semaphore. This situation can easily lead to a deadlock scenario
where we call scheduler with spin lock held.
Signed-off-by: default avatarDenis Kirjanov <kda@linux-powerpc.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 93857edd
...@@ -920,17 +920,17 @@ int hvc_remove(struct hvc_struct *hp) ...@@ -920,17 +920,17 @@ int hvc_remove(struct hvc_struct *hp)
tty = tty_port_tty_get(&hp->port); tty = tty_port_tty_get(&hp->port);
console_lock();
spin_lock_irqsave(&hp->lock, flags); spin_lock_irqsave(&hp->lock, flags);
if (hp->index < MAX_NR_HVC_CONSOLES) { if (hp->index < MAX_NR_HVC_CONSOLES) {
console_lock();
vtermnos[hp->index] = -1; vtermnos[hp->index] = -1;
cons_ops[hp->index] = NULL; cons_ops[hp->index] = NULL;
console_unlock();
} }
/* Don't whack hp->irq because tty_hangup() will need to free the irq. */ /* Don't whack hp->irq because tty_hangup() will need to free the irq. */
spin_unlock_irqrestore(&hp->lock, flags); spin_unlock_irqrestore(&hp->lock, flags);
console_unlock();
/* /*
* We 'put' the instance that was grabbed when the kref instance * We 'put' the instance that was grabbed when the kref instance
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment