From patchwork Sat Nov 29 10:57:33 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 11394 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 CEE96474C1 for ; Sat, 29 Nov 2008 21:58:58 +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 23F71DDDED for ; Sat, 29 Nov 2008 21:57:40 +1100 (EST) Received: by ey-out-2122.google.com with SMTP id 6so693521eyi.15 for ; Sat, 29 Nov 2008 02:57:37 -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=SnHs5tqZtxRafEYOcO/MbLZpvnBF47FTs2pUd0MIlN4=; b=KUjW/HQU/KTQplZUYSneB09F0m+hWmcqRpyX8znCUso+2C5lCfZzHwUGBajhNsNgjS hkkjgSpgY9MK4mZWmaiLmUrqJRwh82Zq2pGDIffWpunmzb05eqGD9iXqyEQgDOpnxNDj 5uhj+P/DlQs79LEZ6iUrIjPXlNeRWxDYpdFWc= 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=suZa1m0welyqvnoGN9clRdB2j738Oqr6RCllGVgGem1kCdqgb5eb/5W4HAXEhcQ+ZN KlgVUXRr2EMZUk+senqAAE0NkQnqaHb3sYqc8N8FzcG+qrtlj5bxyv/5Fp8sldJhdcwb LbqJ+aMKLs/xBax6poNUgi9oMjXCEkpaQkoug= Received: by 10.210.91.7 with SMTP id o7mr4738846ebb.16.1227956257454; Sat, 29 Nov 2008 02:57:37 -0800 (PST) Received: from ?192.168.1.117? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id c25sm2731588ika.14.2008.11.29.02.57.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 Nov 2008 02:57:35 -0800 (PST) Message-ID: <4931201D.7060701@gmail.com> Date: Sat, 29 Nov 2008 05:57:33 -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: powerpc: hv{cs, si}_close() both unsigned hp->count and hvcsd->open_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 and hvcsd->open_count cannot be negative Signed-off-by: Roel Kluin --- Both members of respectively struct hvcs_struct, see vi drivers/char/hvcs.c +262 and struct hvcs_struct, see vi drivers/char/hvsi.c +70 diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c index 473d9b1..b228b84 100644 --- a/drivers/char/hvcs.c +++ b/drivers/char/hvcs.c @@ -1222,7 +1222,8 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp) hvcsd = tty->driver_data; spin_lock_irqsave(&hvcsd->lock, flags); - if (--hvcsd->open_count == 0) { + if (hvcsd->open_count == 1) { + hvcsd->open_count--; vio_disable_interrupts(hvcsd->vdev); @@ -1248,7 +1249,9 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp) free_irq(irq, hvcsd); kref_put(&hvcsd->kref, destroy_hvcs_struct); return; - } else if (hvcsd->open_count < 0) { + } else if (hvcsd->open_count > 1) { + hvcsd->open_count--; + } else { printk(KERN_ERR "HVCS: vty-server@%X open_count: %d" " is missmanaged.\n", hvcsd->vdev->unit_address, hvcsd->open_count); diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index 59c6f9a..d46bccd 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c @@ -875,7 +875,8 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp) spin_lock_irqsave(&hp->lock, flags); - if (--hp->count == 0) { + if (hp->count == 1) { + hp->count--; hp->tty = NULL; hp->inbuf_end = hp->inbuf; /* discard remaining partial packets */ @@ -908,7 +909,9 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp) spin_lock_irqsave(&hp->lock, flags); } - } else if (hp->count < 0) + } else if (hp->count > 1) + hp->count--; + else printk(KERN_ERR "hvsi_close %lu: oops, count is %d\n", hp - hvsi_ports, hp->count);