public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Linux Kernel List <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>
Subject: [PATCH] Convert serial_core oopses to BUG_ON
Date: Sun, 26 Feb 2006 10:05:18 +0000	[thread overview]
Message-ID: <20060226100518.GA31256@flint.arm.linux.org.uk> (raw)

Hi,

With reference to these two bugs:

	http://bugzilla.kernel.org/show_bug.cgi?id=5958
	http://bugzilla.kernel.org/show_bug.cgi?id=6131

it seems that folk are under the impression that serial_core is
responsible for these bugs.  It isn't.

Calling serial functions to flush buffers, or try to send more data
after the port has been closed or hung up is a bug in the code doing
the calling, not in the serial_core driver.

Make this explicitly obvious by adding BUG_ON()'s.

I don't particularly want to add these BUG_ON()'s since they have a
performance impact, but it seems that they're necessary to convey
sufficient understanding about where the bug lies.  The Bluetooth
problem has been around for _ages_ (longer than the entry in bugzilla)
and no one seems the least bit interested in fixing the fscking thing.

I can only hope that adding these BUG_ON()'s provides sufficient
clarity to cause people to look elsewhere.

diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -71,6 +71,11 @@ static void uart_change_pm(struct uart_s
 void uart_write_wakeup(struct uart_port *port)
 {
 	struct uart_info *info = port->info;
+	/*
+	 * This means you called this function _after_ the port was
+	 * closed.  No cookie for you.
+	 */
+	BUG_ON(!info);
 	tasklet_schedule(&info->tlet);
 }
 
@@ -479,6 +484,12 @@ uart_write(struct tty_struct *tty, const
 	unsigned long flags;
 	int c, ret = 0;
 
+	/*
+	 * This means you called this function _after_ the port was
+	 * closed.  No cookie for you.
+	 */
+	BUG_ON(!state);
+
 	if (!circ->buf)
 		return 0;
 
@@ -521,6 +532,12 @@ static void uart_flush_buffer(struct tty
 	struct uart_port *port = state->port;
 	unsigned long flags;
 
+	/*
+	 * This means you called this function _after_ the port was
+	 * closed.  No cookie for you.
+	 */
+	BUG_ON(!state);
+
 	DPRINTK("uart_flush_buffer(%d) called\n", tty->index);
 
 	spin_lock_irqsave(&port->lock, flags);

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

             reply	other threads:[~2006-02-26 10:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-26 10:05 Russell King [this message]
2006-02-26 10:14 ` [PATCH] Convert serial_core oopses to BUG_ON Andrew Morton
2006-02-26 10:18   ` Nick Piggin
2006-02-26 18:17   ` Russell King
2006-02-26 20:00     ` Russell King
2006-02-27 14:13   ` Pavel Machek
2006-02-28 18:17     ` Andrew Morton
2006-02-28 22:01       ` Martin Michlmayr
2006-02-28 23:32         ` Andrew Morton
2006-03-01 17:10           ` Russell King
2006-03-01 19:47             ` Pavel Machek
2006-03-01 22:32               ` Andrew Morton
     [not found] <5Kr1a-6MF-15@gated-at.bofh.it>
     [not found] ` <5KraE-6XP-15@gated-at.bofh.it>
     [not found]   ` <5KyFv-RL-15@gated-at.bofh.it>
2006-02-26 22:34     ` Karol Kozimor
2006-02-26 22:41       ` Russell King
     [not found] <20060227162827.GC2389@ucw.cz>
2006-03-01 19:00 ` Pavel Machek

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=20060226100518.GA31256@flint.arm.linux.org.uk \
    --to=rmk+lkml@arm.linux.org.uk \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.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