summaryrefslogtreecommitdiff
path: root/drivers/tty/hvc
diff options
context:
space:
mode:
authorDenis Kirjanov <kda@linux-powerpc.org>2017-03-30 17:06:19 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-31 12:37:13 +0300
commit19fa6e601b251f13400767813372944b3e2f444b (patch)
treef196d95a9163a964826db79b5a9d7b79fec06ffc /drivers/tty/hvc
parent93857edd9829e144acb6c7e72d593f6e01aead66 (diff)
downloadlinux-19fa6e601b251f13400767813372944b3e2f444b.tar.xz
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: Denis Kirjanov <kda@linux-powerpc.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/hvc')
-rw-r--r--drivers/tty/hvc/hvc_console.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index b19ae36a05ec..a8d399188242 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -920,17 +920,17 @@ int hvc_remove(struct hvc_struct *hp)
tty = tty_port_tty_get(&hp->port);
+ console_lock();
spin_lock_irqsave(&hp->lock, flags);
if (hp->index < MAX_NR_HVC_CONSOLES) {
- console_lock();
vtermnos[hp->index] = -1;
cons_ops[hp->index] = NULL;
- console_unlock();
}
/* Don't whack hp->irq because tty_hangup() will need to free the irq. */
spin_unlock_irqrestore(&hp->lock, flags);
+ console_unlock();
/*
* We 'put' the instance that was grabbed when the kref instance