Skip to contentSkip to conversation

powerpc: hvc_close() unsigned hp->count cannot be negative

PATCH New roel kluin 1 participant 1 message Nov 29, 2008 Char and misc drivers

lore
Share & tools
lore

roel kluin

author
#0 lore raw

PATCH 1/1 powerpc: hvc_close() unsigned hp->count cannot be negative

unsigned hp->count cannot be negative

---
Similar to the previous patch but with lock. For hvc_struct, see vi drivers/char/hvc_console.h +47

drivers/char/hvc_console.c +5 -2
index 5b819b1..337f6c6 100644
@@ -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);