From patchwork Sat Nov 29 12:41:32 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 11401 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id A4356DDE00 for ; Sat, 29 Nov 2008 23:42:55 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.24]) by ozlabs.org (Postfix) with ESMTP id 0BEDBDDDF5 for ; Sat, 29 Nov 2008 23:41:51 +1100 (EST) Received: by ey-out-2122.google.com with SMTP id 6so703857eyi.15 for ; Sat, 29 Nov 2008 04:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=cG09srHM1J9AbmLoY+yIfTrPTREGjfEcCsslaJ7UlLw=; b=xCuo2WoSen16m+MCqU/8/KlY2e87qTjoPEw6hIBJghdlTVFUNH/tw7SqO9VOZiXZJI tGZvCnok1zPQiPeLqytopIRypl+Y1bbbuBYZpq0MR1YJwPsOPj6PB/J6Im6F6J5mqoTJ YKUIsa1/AiyQkAc3hiE1Ry0Lh1uyAqGxj/Mm8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=x4orZ0iAxa2Ksr6GO4XW9K5bJY4JfqOpBV4lSOOe054JWreFveTr81RnEXlCC2BE5U ATpO6BdygwmJn/kuCK2j4dDqH/M6K1MbnW8Kte5penCtR6ylCTAmXH29FxnAiWY9wY1O PnZMUDnBm8gWVu5nYYkJoU9nLzrvLSNjVv/zc= Received: by 10.210.66.1 with SMTP id o1mr10096561eba.193.1227962509100; Sat, 29 Nov 2008 04:41:49 -0800 (PST) Received: from ?192.168.1.117? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id z33sm2979084ikz.16.2008.11.29.04.41.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 Nov 2008 04:41:36 -0800 (PST) Message-ID: <4931387C.4000001@gmail.com> Date: Sat, 29 Nov 2008 07:41:32 -0500 From: roel kluin User-Agent: Mozilla-Thunderbird 2.0.0.9 (X11/20080110) MIME-Version: 1.0 To: benh@kernel.crashing.org, linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] powerpc: hvc_close() unsigned hp->count cannot be negative X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org unsigned hp->count cannot be negative Signed-off-by: Roel Kluin --- 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);