Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "tty: hvc: Fix data abort due to race in hvc_open"

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>

+2 -14
+2 -14
drivers/tty/hvc/hvc_console.c
··· 75 75 */ 76 76 static DEFINE_MUTEX(hvc_structs_mutex); 77 77 78 - /* Mutex to serialize hvc_open */ 79 - static DEFINE_MUTEX(hvc_open_mutex); 80 78 /* 81 79 * This value is used to assign a tty->index value to a hvc_struct based 82 80 * upon order of exposure via hvc_probe(), when we can not match it to ··· 346 348 */ 347 349 static int hvc_open(struct tty_struct *tty, struct file * filp) 348 350 { 349 - struct hvc_struct *hp; 351 + struct hvc_struct *hp = tty->driver_data; 350 352 unsigned long flags; 351 353 int rc = 0; 352 - 353 - mutex_lock(&hvc_open_mutex); 354 - 355 - hp = tty->driver_data; 356 - if (!hp) { 357 - rc = -EIO; 358 - goto out; 359 - } 360 354 361 355 spin_lock_irqsave(&hp->port.lock, flags); 362 356 /* Check and then increment for fast path open. */ 363 357 if (hp->port.count++ > 0) { 364 358 spin_unlock_irqrestore(&hp->port.lock, flags); 365 359 hvc_kick(); 366 - goto out; 360 + return 0; 367 361 } /* else count == 0 */ 368 362 spin_unlock_irqrestore(&hp->port.lock, flags); 369 363 ··· 384 394 /* Force wakeup of the polling thread */ 385 395 hvc_kick(); 386 396 387 - out: 388 - mutex_unlock(&hvc_open_mutex); 389 397 return rc; 390 398 } 391 399