Skip to contentSkip to conversation

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

PATCH In review Paul Mackerras 4 participants 8 messages Nov 14, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/tty/hvc/hvc_console.c |    7 -------
 1 file changed, 7 deletions(-)
drivers/tty/hvc/hvc_console.c +0 -7
index a5dec1c..13ee53b 100644
@@ -424,7 +424,6 @@ static void hvc_hangup(struct tty_struct *tty)
 {
 	struct hvc_struct *hp = tty->driver_data;
 	unsigned long flags;
-	int temp_open_count;
 
 	if (!hp)
 		return;
@@ -444,7 +443,6 @@ static void hvc_hangup(struct tty_struct *tty)
 		return;
 	}
 
-	temp_open_count = hp->port.count;
 	hp->port.count = 0;
 	spin_unlock_irqrestore(&hp->port.lock, flags);
 	tty_port_tty_set(&hp->port, NULL);
@@ -453,11 +451,6 @@ static void hvc_hangup(struct tty_struct *tty)
 
 	if (hp->ops->notifier_hangup)
 		hp->ops->notifier_hangup(hp, hp->data);
-
-	while(temp_open_count) {
-		--temp_open_count;
-		tty_port_put(&hp->port);
-	}
 }
 
 /*
Signature · 1 line
1.7.10.rc3.219.g53414
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Paul Mackerras

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.

Quoted 8 lines

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.

Oh yeah. Thanks.

Quoted 39 lines
---
 drivers/tty/hvc/hvc_console.c |    7 -------
 1 file changed, 7 deletions(-)
drivers/tty/hvc/hvc_console.c +0 -7
index a5dec1c..13ee53b 100644
@@ -424,7 +424,6 @@ static void hvc_hangup(struct tty_struct *tty)
 {
 	struct hvc_struct *hp = tty->driver_data;
 	unsigned long flags;
-	int temp_open_count;
 
 	if (!hp)
 		return;
@@ -444,7 +443,6 @@ static void hvc_hangup(struct tty_struct *tty)
 		return;
 	}
 
-	temp_open_count = hp->port.count;
 	hp->port.count = 0;
 	spin_unlock_irqrestore(&hp->port.lock, flags);
 	tty_port_tty_set(&hp->port, NULL);
@@ -453,11 +451,6 @@ static void hvc_hangup(struct tty_struct *tty)
 
 	if (hp->ops->notifier_hangup)
 		hp->ops->notifier_hangup(hp, hp->data);
-
-	while(temp_open_count) {
-		--temp_open_count;
-		tty_port_put(&hp->port);
-	}
 }
 
 /*
Signature · 2 lines
js
suse labs
#2 lore raw
Quoted 5 lines · Jiri Slaby
Quoted 1 line

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

Oh yeah. Thanks.

So who's merging it ?

Cheers,
Ben.

Quoted 41 lines
Quoted 39 lines
---
 drivers/tty/hvc/hvc_console.c |    7 -------
 1 file changed, 7 deletions(-)
drivers/tty/hvc/hvc_console.c +0 -7
index a5dec1c..13ee53b 100644
@@ -424,7 +424,6 @@ static void hvc_hangup(struct tty_struct *tty)
 {
 	struct hvc_struct *hp = tty->driver_data;
 	unsigned long flags;
-	int temp_open_count;
 
 	if (!hp)
 		return;
@@ -444,7 +443,6 @@ static void hvc_hangup(struct tty_struct *tty)
 		return;
 	}
 
-	temp_open_count = hp->port.count;
 	hp->port.count = 0;
 	spin_unlock_irqrestore(&hp->port.lock, flags);
 	tty_port_tty_set(&hp->port, NULL);
@@ -453,11 +451,6 @@ static void hvc_hangup(struct tty_struct *tty)
 
 	if (hp->ops->notifier_hangup)
 		hp->ops->notifier_hangup(hp, hp->data);
-
-	while(temp_open_count) {
-		--temp_open_count;
-		tty_port_put(&hp->port);
-	}
 }
 
 /*
maintainer
#3 lore raw
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 5 lines · Jiri Slaby
Quoted 1 line

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

Oh yeah. Thanks.

So who's merging it ?

Give me a chance to at least wake up please :)

I will.

greg k-h

#4 lore raw
Quoted 3 lines · Greg KH
Quoted 1 line

So who's merging it ?

Give me a chance to at least wake up please :)

Sure ;-) Just asking since I'm about to cook up a powerpc batch :-)

Quoted 1 line

I will.

Thanks ! It should go into stable 3.6 as well.

Cheers,
Ben.

maintainer
#5 lore raw
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 3 lines · Greg KH
Quoted 1 line

So who's merging it ?

Give me a chance to at least wake up please :)

Sure ;-) Just asking since I'm about to cook up a powerpc batch :-)

It's now in my tree, and will get to Linus in time for 3.7.

Quoted 3 lines
Quoted 1 line

I will.

Thanks ! It should go into stable 3.6 as well.

Why? The offending patch didn't show up until 3.7-rc1.

thanks,

greg k-h

#6 lore raw
Quoted 3 lines · Greg KH
Quoted 1 line

Thanks ! It should go into stable 3.6 as well.

Why? The offending patch didn't show up until 3.7-rc1.

Ah, my bad, I though Paulus had observed the problem with 3.6 as well but it looks like you are right. So 3.7 then.

Thanks.

Cheers,
Ben.

#7 lore raw
In reply to Greg KH
Quoted 9 lines · Greg KH
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 3 lines · Greg KH
Quoted 1 line

So who's merging it ?

Give me a chance to at least wake up please :)

Sure ;-) Just asking since I'm about to cook up a powerpc batch :-)

It's now in my tree, and will get to Linus in time for 3.7.

Turns out I stuffed up the commit message a bit, I talk about kref_put and tty_kref_put when I should be talking about tty_port_put. If there is still a chance to update the commit message, that would be good. The patch itself is correct.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I will.

Thanks ! It should go into stable 3.6 as well.

Why? The offending patch didn't show up until 3.7-rc1.

Yes. I had thought it was in 3.6 but it isn't.

Paul.