Skip to content

Commit feb6c2d

Browse files
gregkhSasha Levin
authored andcommitted
Revert "tty: hvc: Fix data abort due to race in hvc_open"
commit cf9c944 upstream. This reverts commit e2bd1dc. 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 <[email protected]> Reported-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: Raghavendra Rao Ananta <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent edb930b commit feb6c2d

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

drivers/tty/hvc/hvc_console.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ static LIST_HEAD(hvc_structs);
7575
*/
7676
static DEFINE_MUTEX(hvc_structs_mutex);
7777

78-
/* Mutex to serialize hvc_open */
79-
static DEFINE_MUTEX(hvc_open_mutex);
8078
/*
8179
* This value is used to assign a tty->index value to a hvc_struct based
8280
* upon order of exposure via hvc_probe(), when we can not match it to
@@ -348,24 +346,16 @@ static int hvc_install(struct tty_driver *driver, struct tty_struct *tty)
348346
*/
349347
static int hvc_open(struct tty_struct *tty, struct file * filp)
350348
{
351-
struct hvc_struct *hp;
349+
struct hvc_struct *hp = tty->driver_data;
352350
unsigned long flags;
353351
int rc = 0;
354352

355-
mutex_lock(&hvc_open_mutex);
356-
357-
hp = tty->driver_data;
358-
if (!hp) {
359-
rc = -EIO;
360-
goto out;
361-
}
362-
363353
spin_lock_irqsave(&hp->port.lock, flags);
364354
/* Check and then increment for fast path open. */
365355
if (hp->port.count++ > 0) {
366356
spin_unlock_irqrestore(&hp->port.lock, flags);
367357
hvc_kick();
368-
goto out;
358+
return 0;
369359
} /* else count == 0 */
370360
spin_unlock_irqrestore(&hp->port.lock, flags);
371361

@@ -393,8 +383,6 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
393383
/* Force wakeup of the polling thread */
394384
hvc_kick();
395385

396-
out:
397-
mutex_unlock(&hvc_open_mutex);
398386
return rc;
399387
}
400388

0 commit comments

Comments
 (0)