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

TTY: hvc_console, fix port reference count going to zero prematurely

Commit bdb498c20040 "TTY: hvc_console, add tty install" took the port
refcounting out of hvc_open()/hvc_close(), but failed to remove the
kref_put() and tty_kref_put() calls in hvc_hangup() that were there to
remove the extra references that hvc_open() had taken.

The result was that doing a vhangup() when the current terminal was
a hvc_console, then closing the current terminal, would end up calling
destroy_hvc_struct() and making the port disappear entirely. This
meant that Fedora 17 systems would boot up but then not display the
login prompt on the console, and attempts to open /dev/hvc0 would
give a "No such device" error.

This fixes it by removing the extra kref_put() and tty_kref_put() calls.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Paul Mackerras and committed by
Greg Kroah-Hartman
c019bc11 77b67063

-7
-7
drivers/tty/hvc/hvc_console.c
··· 424 424 { 425 425 struct hvc_struct *hp = tty->driver_data; 426 426 unsigned long flags; 427 - int temp_open_count; 428 427 429 428 if (!hp) 430 429 return; ··· 443 444 return; 444 445 } 445 446 446 - temp_open_count = hp->port.count; 447 447 hp->port.count = 0; 448 448 spin_unlock_irqrestore(&hp->port.lock, flags); 449 449 tty_port_tty_set(&hp->port, NULL); ··· 451 453 452 454 if (hp->ops->notifier_hangup) 453 455 hp->ops->notifier_hangup(hp, hp->data); 454 - 455 - while(temp_open_count) { 456 - --temp_open_count; 457 - tty_port_put(&hp->port); 458 - } 459 456 } 460 457 461 458 /*