All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: hvc_close() unsigned hp->count cannot be negative
@ 2008-11-29 12:41 roel kluin
  0 siblings, 0 replies; only message in thread
From: roel kluin @ 2008-11-29 12:41 UTC (permalink / raw)
  To: benh, linuxppc-dev, linux-kernel

unsigned hp->count cannot be negative

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Similar to the previous patch but with lock. For hvc_struct, see
vi drivers/char/hvc_console.h +47

diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 5b819b1..337f6c6 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -366,7 +366,8 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
 	hp = tty->driver_data;
 	spin_lock_irqsave(&hp->lock, flags);
 
-	if (--hp->count == 0) {
+	if (hp->count == 1) {
+		hp->count--;
 		/* We are done with the tty pointer now. */
 		hp->tty = NULL;
 		spin_unlock_irqrestore(&hp->lock, flags);
@@ -384,7 +385,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
 		 */
 		tty_wait_until_sent(tty, HVC_CLOSE_WAIT);
 	} else {
-		if (hp->count < 0)
+		if (hp->count > 1)
+			hp->count--;
+		else
 			printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
 				hp->vtermno, hp->count);
 		spin_unlock_irqrestore(&hp->lock, flags);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-29 12:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-29 12:41 [PATCH] powerpc: hvc_close() unsigned hp->count cannot be negative roel kluin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.