diff options
Diffstat (limited to 'net/bluetooth/rfcomm')
| -rw-r--r-- | net/bluetooth/rfcomm/sock.c | 9 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/tty.c | 22 |
2 files changed, 21 insertions, 10 deletions
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 544d65b7baa7..cb7e855f0828 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
| @@ -557,7 +557,6 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 557 | struct sock *sk = sock->sk; | 557 | struct sock *sk = sock->sk; |
| 558 | struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc; | 558 | struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc; |
| 559 | struct sk_buff *skb; | 559 | struct sk_buff *skb; |
| 560 | int err; | ||
| 561 | int sent = 0; | 560 | int sent = 0; |
| 562 | 561 | ||
| 563 | if (msg->msg_flags & MSG_OOB) | 562 | if (msg->msg_flags & MSG_OOB) |
| @@ -572,6 +571,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 572 | 571 | ||
| 573 | while (len) { | 572 | while (len) { |
| 574 | size_t size = min_t(size_t, len, d->mtu); | 573 | size_t size = min_t(size_t, len, d->mtu); |
| 574 | int err; | ||
| 575 | 575 | ||
| 576 | skb = sock_alloc_send_skb(sk, size + RFCOMM_SKB_RESERVE, | 576 | skb = sock_alloc_send_skb(sk, size + RFCOMM_SKB_RESERVE, |
| 577 | msg->msg_flags & MSG_DONTWAIT, &err); | 577 | msg->msg_flags & MSG_DONTWAIT, &err); |
| @@ -582,13 +582,16 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 582 | err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); | 582 | err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size); |
| 583 | if (err) { | 583 | if (err) { |
| 584 | kfree_skb(skb); | 584 | kfree_skb(skb); |
| 585 | sent = err; | 585 | if (sent == 0) |
| 586 | sent = err; | ||
| 586 | break; | 587 | break; |
| 587 | } | 588 | } |
| 588 | 589 | ||
| 589 | err = rfcomm_dlc_send(d, skb); | 590 | err = rfcomm_dlc_send(d, skb); |
| 590 | if (err < 0) { | 591 | if (err < 0) { |
| 591 | kfree_skb(skb); | 592 | kfree_skb(skb); |
| 593 | if (sent == 0) | ||
| 594 | sent = err; | ||
| 592 | break; | 595 | break; |
| 593 | } | 596 | } |
| 594 | 597 | ||
| @@ -598,7 +601,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
| 598 | 601 | ||
| 599 | release_sock(sk); | 602 | release_sock(sk); |
| 600 | 603 | ||
| 601 | return sent ? sent : err; | 604 | return sent; |
| 602 | } | 605 | } |
| 603 | 606 | ||
| 604 | static long rfcomm_sock_data_wait(struct sock *sk, long timeo) | 607 | static long rfcomm_sock_data_wait(struct sock *sk, long timeo) |
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)) |
