public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: Evan Parker <nave@stanford.edu>
Cc: linux-kernel@vger.kernel.org, mc@cs.stanford.edu,
	tytso@valinux.com, alan@lxorguk.ukuu.org.uk,
	torvalds@transmeta.com
Subject: Re: [CHECKER] repetitive/contradictory comparison bugs for 2.4.7
Date: Wed, 25 Jul 2001 09:27:32 +0100	[thread overview]
Message-ID: <20010725092732.A21614@flint.arm.linux.org.uk> (raw)
In-Reply-To: <Pine.GSO.4.31.0107241704430.11742-100000@myth10.Stanford.EDU>
In-Reply-To: <Pine.GSO.4.31.0107241704430.11742-100000@myth10.Stanford.EDU>; from nave@stanford.edu on Tue, Jul 24, 2001 at 05:08:23PM -0700

On Tue, Jul 24, 2001 at 05:08:23PM -0700, Evan Parker wrote:
> One of them, the last one, is pretty clearly a bug, but the
> other 10 are questionable.  Those 10 are all simple variations on the
> following code:
> 
> Start --->
> 	if (!tmp_buf) {
> 		page = get_free_page(GFP_KERNEL);
> 
> Error --->
> 		if (tmp_buf)
> 			free_page(page);
> 		else
> 			tmp_buf = (unsigned char *) page;
> 	}

The following patch fixes this:

--- orig/drivers/char/serial.c	Sat Jul 21 10:46:42 2001
+++ linux/drivers/char/serial.c	Wed Jul 25 09:19:49 2001
@@ -3157,17 +3157,17 @@
 	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 #endif
 
+	down(&tmp_buf_sem);
 	if (!tmp_buf) {
 		page = get_zeroed_page(GFP_KERNEL);
 		if (!page) {
+			up(&tmp_buf_sem);
 			MOD_DEC_USE_COUNT;
 			return -ENOMEM;
 		}
-		if (tmp_buf)
-			free_page(page);
-		else
-			tmp_buf = (unsigned char *) page;
+		tmp_buf = (unsigned char *) page;
 	}
+	up(&tmp_buf_sem);
 
 	/*
 	 * If the port is the middle of closing, bail out now
@@ -5666,12 +5666,14 @@
 		if (DEACTIVATE_FUNC(brd->dev))
 			(DEACTIVATE_FUNC(brd->dev))(brd->dev);
 	}
-#endif	
+#endif
+	down(&tmp_buf_sem);
 	if (tmp_buf) {
 		unsigned long pg = (unsigned long) tmp_buf;
 		tmp_buf = NULL;
 		free_page(pg);
 	}
+	up(&tmp_buf_sem);
 	
 #ifdef ENABLE_SERIAL_PCI
 	if (serial_pci_driver.name[0])


--
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


  parent reply	other threads:[~2001-07-25  8:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-25  0:08 [CHECKER] repetitive/contradictory comparison bugs for 2.4.7 Evan Parker
2001-07-25  0:51 ` Neil Brown
2001-07-25  8:27 ` Russell King [this message]
2001-07-25 13:34 ` Alan Cox
2001-07-26  1:13   ` Dawson Engler
2001-07-26 19:54     ` Alex Bligh - linux-kernel
2001-07-26 20:15       ` Russell King
2001-07-26 22:07         ` Alan Cox
2001-07-26 22:06       ` Alan Cox
2001-07-26 22:24         ` Alex Bligh - linux-kernel

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=20010725092732.A21614@flint.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mc@cs.stanford.edu \
    --cc=nave@stanford.edu \
    --cc=torvalds@transmeta.com \
    --cc=tytso@valinux.com \
    /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