summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-12 10:22:44 +0200
committerSasha Levin <sashal@kernel.org>2020-06-30 15:38:10 -0400
commitf1bd26cf65a3f3d9dea9218eac4470af1dfcfb1e (patch)
tree821760be90131c1b31a1d093172f93f96082133f
parent115267e8d9fce8d5efe0949f1d2e5cee30441cf7 (diff)
Revert "tty: hvc: Fix data abort due to race in hvc_open"
commit cf9c94456ebafc6d75a834e58dfdc8ae71a3acbc upstream. This reverts commit e2bd1dcbe1aa34ff5570b3427c530e4332ecf0fe. In discussion on the mailing list, it has been determined that this is not the correct type of fix for this issue. Revert it so that we can do this correctly. Reported-by: Jiri Slaby <jslaby@suse.cz> Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20200428032601.22127-1-rananta@codeaurora.org Cc: Raghavendra Rao Ananta <rananta@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/hvc/hvc_console.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 663cbe3669e1..d52221ae1b85 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -88,8 +88,6 @@ static LIST_HEAD(hvc_structs);
*/
static DEFINE_SPINLOCK(hvc_structs_lock);
-/* Mutex to serialize hvc_open */
-static DEFINE_MUTEX(hvc_open_mutex);
/*
* This value is used to assign a tty->index value to a hvc_struct based
* upon order of exposure via hvc_probe(), when we can not match it to
@@ -334,24 +332,16 @@ static int hvc_install(struct tty_driver *driver, struct tty_struct *tty)
*/
static int hvc_open(struct tty_struct *tty, struct file * filp)
{
- struct hvc_struct *hp;
+ struct hvc_struct *hp = tty->driver_data;
unsigned long flags;
int rc = 0;
- mutex_lock(&hvc_open_mutex);
-
- hp = tty->driver_data;
- if (!hp) {
- rc = -EIO;
- goto out;
- }
-
spin_lock_irqsave(&hp->port.lock, flags);
/* Check and then increment for fast path open. */
if (hp->port.count++ > 0) {
spin_unlock_irqrestore(&hp->port.lock, flags);
hvc_kick();
- goto out;
+ return 0;
} /* else count == 0 */
spin_unlock_irqrestore(&hp->port.lock, flags);
@@ -379,8 +369,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
/* Force wakeup of the polling thread */
hvc_kick();
-out:
- mutex_unlock(&hvc_open_mutex);
return rc;
}