diff options
Diffstat (limited to 'net/bluetooth/rfcomm/tty.c')
| -rw-r--r-- | net/bluetooth/rfcomm/tty.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index e0e0d09023b2..eb2b52484c70 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
| @@ -697,9 +697,13 @@ static int rfcomm_tty_write_room(struct tty_struct *tty) | |||
| 697 | 697 | ||
| 698 | BT_DBG("tty %p", tty); | 698 | BT_DBG("tty %p", tty); |
| 699 | 699 | ||
| 700 | if (!dev || !dev->dlc) | ||
| 701 | return 0; | ||
| 702 | |||
| 700 | room = rfcomm_room(dev->dlc) - atomic_read(&dev->wmem_alloc); | 703 | room = rfcomm_room(dev->dlc) - atomic_read(&dev->wmem_alloc); |
| 701 | if (room < 0) | 704 | if (room < 0) |
| 702 | room = 0; | 705 | room = 0; |
| 706 | |||
| 703 | return room; | 707 | return room; |
| 704 | } | 708 | } |
| 705 | 709 | ||
| @@ -915,12 +919,14 @@ static void rfcomm_tty_unthrottle(struct tty_struct *tty) | |||
| 915 | static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) | 919 | static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) |
| 916 | { | 920 | { |
| 917 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; | 921 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; |
| 918 | struct rfcomm_dlc *dlc = dev->dlc; | ||
| 919 | 922 | ||
| 920 | BT_DBG("tty %p dev %p", tty, dev); | 923 | BT_DBG("tty %p dev %p", tty, dev); |
| 921 | 924 | ||
| 922 | if (!skb_queue_empty(&dlc->tx_queue)) | 925 | if (!dev || !dev->dlc) |
| 923 | return dlc->mtu; | 926 | return 0; |
| 927 | |||
| 928 | if (!skb_queue_empty(&dev->dlc->tx_queue)) | ||
| 929 | return dev->dlc->mtu; | ||
| 924 | 930 | ||
| 925 | return 0; | 931 | return 0; |
| 926 | } | 932 | } |
| @@ -928,11 +934,12 @@ static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) | |||
| 928 | static void rfcomm_tty_flush_buffer(struct tty_struct *tty) | 934 | static void rfcomm_tty_flush_buffer(struct tty_struct *tty) |
| 929 | { | 935 | { |
| 930 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; | 936 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; |
| 931 | if (!dev) | ||
| 932 | return; | ||
| 933 | 937 | ||
| 934 | BT_DBG("tty %p dev %p", tty, dev); | 938 | BT_DBG("tty %p dev %p", tty, dev); |
| 935 | 939 | ||
| 940 | if (!dev || !dev->dlc) | ||
| 941 | return; | ||
| 942 | |||
| 936 | skb_queue_purge(&dev->dlc->tx_queue); | 943 | skb_queue_purge(&dev->dlc->tx_queue); |
| 937 | 944 | ||
| 938 | if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup) | 945 | if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && tty->ldisc.write_wakeup) |
| @@ -952,11 +959,12 @@ static void rfcomm_tty_wait_until_sent(struct tty_struct *tty, int timeout) | |||
| 952 | static void rfcomm_tty_hangup(struct tty_struct *tty) | 959 | static void rfcomm_tty_hangup(struct tty_struct *tty) |
| 953 | { | 960 | { |
| 954 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; | 961 | struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; |
| 955 | if (!dev) | ||
| 956 | return; | ||
| 957 | 962 | ||
| 958 | BT_DBG("tty %p dev %p", tty, dev); | 963 | BT_DBG("tty %p dev %p", tty, dev); |
| 959 | 964 | ||
| 965 | if (!dev) | ||
| 966 | return; | ||
| 967 | |||
| 960 | rfcomm_tty_flush_buffer(tty); | 968 | rfcomm_tty_flush_buffer(tty); |
| 961 | 969 | ||
| 962 | if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) | 970 | if (test_bit(RFCOMM_RELEASE_ONHUP, &dev->flags)) |
