diff options
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/serial_core.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c index 95fb4939c675..cc1faa31d124 100644 --- a/drivers/serial/serial_core.c +++ b/drivers/serial/serial_core.c | |||
@@ -71,6 +71,11 @@ static void uart_change_pm(struct uart_state *state, int pm_state); | |||
71 | void uart_write_wakeup(struct uart_port *port) | 71 | void uart_write_wakeup(struct uart_port *port) |
72 | { | 72 | { |
73 | struct uart_info *info = port->info; | 73 | struct uart_info *info = port->info; |
74 | /* | ||
75 | * This means you called this function _after_ the port was | ||
76 | * closed. No cookie for you. | ||
77 | */ | ||
78 | BUG_ON(!info); | ||
74 | tasklet_schedule(&info->tlet); | 79 | tasklet_schedule(&info->tlet); |
75 | } | 80 | } |
76 | 81 | ||
@@ -471,14 +476,26 @@ static void uart_flush_chars(struct tty_struct *tty) | |||
471 | } | 476 | } |
472 | 477 | ||
473 | static int | 478 | static int |
474 | uart_write(struct tty_struct *tty, const unsigned char * buf, int count) | 479 | uart_write(struct tty_struct *tty, const unsigned char *buf, int count) |
475 | { | 480 | { |
476 | struct uart_state *state = tty->driver_data; | 481 | struct uart_state *state = tty->driver_data; |
477 | struct uart_port *port = state->port; | 482 | struct uart_port *port; |
478 | struct circ_buf *circ = &state->info->xmit; | 483 | struct circ_buf *circ; |
479 | unsigned long flags; | 484 | unsigned long flags; |
480 | int c, ret = 0; | 485 | int c, ret = 0; |
481 | 486 | ||
487 | /* | ||
488 | * This means you called this function _after_ the port was | ||
489 | * closed. No cookie for you. | ||
490 | */ | ||
491 | if (!state || !state->info) { | ||
492 | WARN_ON(1); | ||
493 | return -EL3HLT; | ||
494 | } | ||
495 | |||
496 | port = state->port; | ||
497 | circ = &state->info->xmit; | ||
498 | |||
482 | if (!circ->buf) | 499 | if (!circ->buf) |
483 | return 0; | 500 | return 0; |
484 | 501 | ||
@@ -521,6 +538,15 @@ static void uart_flush_buffer(struct tty_struct *tty) | |||
521 | struct uart_port *port = state->port; | 538 | struct uart_port *port = state->port; |
522 | unsigned long flags; | 539 | unsigned long flags; |
523 | 540 | ||
541 | /* | ||
542 | * This means you called this function _after_ the port was | ||
543 | * closed. No cookie for you. | ||
544 | */ | ||
545 | if (!state || !state->info) { | ||
546 | WARN_ON(1); | ||
547 | return; | ||
548 | } | ||
549 | |||
524 | DPRINTK("uart_flush_buffer(%d) called\n", tty->index); | 550 | DPRINTK("uart_flush_buffer(%d) called\n", tty->index); |
525 | 551 | ||
526 | spin_lock_irqsave(&port->lock, flags); | 552 | spin_lock_irqsave(&port->lock, flags); |