[Bluetooth] Avoid NULL pointer dereference with tty->driver
[pandora-kernel.git] / drivers / bluetooth / hci_ldisc.c
index 573ff6c..93ba25b 100644 (file)
@@ -23,7 +23,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <linux/kernel.h>
@@ -192,7 +191,7 @@ static int hci_uart_flush(struct hci_dev *hdev)
 
        /* Flush any pending characters in the driver and discipline. */
        tty_ldisc_flush(tty);
-       if (tty->driver->flush_buffer)
+       if (tty->driver && tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
 
        if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
@@ -279,6 +278,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 
        tty->disc_data = hu;
        hu->tty = tty;
+       tty->receive_room = 65536;
 
        spin_lock_init(&hu->rx_lock);
 
@@ -290,7 +290,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
        if (tty->ldisc.flush_buffer)
                tty->ldisc.flush_buffer(tty);
 
-       if (tty->driver->flush_buffer)
+       if (tty->driver && tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
 
        return 0;
@@ -348,20 +348,6 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
                hci_uart_tx_wakeup(hu);
 }
 
-/* hci_uart_tty_room()
- * 
- *    Callback function from tty driver. Return the amount of 
- *    space left in the receiver's buffer to decide if remote
- *    transmitter is to be throttled.
- *
- * Arguments:        tty    pointer to associated tty instance data
- * Return Value:    number of bytes left in receive buffer
- */
-static int hci_uart_tty_room (struct tty_struct *tty)
-{
-       return 65536;
-}
-
 /* hci_uart_tty_receive()
  * 
  *     Called by tty low level driver when receive data is
@@ -544,7 +530,6 @@ static int __init hci_uart_init(void)
        hci_uart_ldisc.write            = hci_uart_tty_write;
        hci_uart_ldisc.ioctl            = hci_uart_tty_ioctl;
        hci_uart_ldisc.poll             = hci_uart_tty_poll;
-       hci_uart_ldisc.receive_room     = hci_uart_tty_room;
        hci_uart_ldisc.receive_buf      = hci_uart_tty_receive;
        hci_uart_ldisc.write_wakeup     = hci_uart_tty_wakeup;
        hci_uart_ldisc.owner            = THIS_MODULE;