linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
[parent not found: <5Kr1a-6MF-15@gated-at.bofh.it>]
* [PATCH] Convert serial_core oopses to BUG_ON
@ 2006-02-26 10:05 Russell King
  2006-02-26 10:14 ` Andrew Morton
  0 siblings, 1 reply; 15+ messages in thread
From: Russell King @ 2006-02-26 10:05 UTC (permalink / raw)
  To: Linux Kernel List; +Cc: Andrew Morton

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-03-01 22:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20060227162827.GC2389@ucw.cz>
2006-03-01 19:00 ` [PATCH] Convert serial_core oopses to BUG_ON Pavel Machek
     [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
2006-02-26 10:05 Russell King
2006-02-26 10:14 ` 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

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).