From: roel kluin <roel.kluin@gmail.com>
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
Date: Sat, 29 Nov 2008 05:57:33 -0500 [thread overview]
Message-ID: <4931201D.7060701@gmail.com> (raw)
unsigned hp->count and hvcsd->open_count cannot be negative
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
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);
next reply other threads:[~2008-11-29 10:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-29 10:57 roel kluin [this message]
2008-11-29 12:54 ` powerpc: hv{cs, si}_close() both unsigned hp->count and hvcsd->open_count cannot be negative Andreas Schwab
2008-11-29 13:27 ` roel kluin
2008-11-29 15:01 ` Andreas Schwab
2008-11-29 23:20 ` Paul Mackerras
2008-11-30 11:16 ` Alan Cox
2008-11-30 21:23 ` Paul Mackerras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4931201D.7060701@gmail.com \
--to=roel.kluin@gmail.com \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).