diff options
Diffstat (limited to 'net/bluetooth/rfcomm/tty.c')
-rw-r--r-- | net/bluetooth/rfcomm/tty.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index a9b81f5dacd1..2575c2db6404 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -58,9 +58,9 @@ struct rfcomm_dev { | |||
58 | 58 | ||
59 | bdaddr_t src; | 59 | bdaddr_t src; |
60 | bdaddr_t dst; | 60 | bdaddr_t dst; |
61 | u8 channel; | 61 | u8 channel; |
62 | 62 | ||
63 | uint modem_status; | 63 | uint modem_status; |
64 | 64 | ||
65 | struct rfcomm_dlc *dlc; | 65 | struct rfcomm_dlc *dlc; |
66 | struct tty_struct *tty; | 66 | struct tty_struct *tty; |
@@ -69,7 +69,7 @@ struct rfcomm_dev { | |||
69 | 69 | ||
70 | struct device *tty_dev; | 70 | struct device *tty_dev; |
71 | 71 | ||
72 | atomic_t wmem_alloc; | 72 | atomic_t wmem_alloc; |
73 | 73 | ||
74 | struct sk_buff_head pending; | 74 | struct sk_buff_head pending; |
75 | }; | 75 | }; |
@@ -431,7 +431,8 @@ static int rfcomm_release_dev(void __user *arg) | |||
431 | 431 | ||
432 | BT_DBG("dev_id %d flags 0x%x", req.dev_id, req.flags); | 432 | BT_DBG("dev_id %d flags 0x%x", req.dev_id, req.flags); |
433 | 433 | ||
434 | if (!(dev = rfcomm_dev_get(req.dev_id))) | 434 | dev = rfcomm_dev_get(req.dev_id); |
435 | if (!dev) | ||
435 | return -ENODEV; | 436 | return -ENODEV; |
436 | 437 | ||
437 | if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) { | 438 | if (dev->flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN)) { |
@@ -470,7 +471,8 @@ static int rfcomm_get_dev_list(void __user *arg) | |||
470 | 471 | ||
471 | size = sizeof(*dl) + dev_num * sizeof(*di); | 472 | size = sizeof(*dl) + dev_num * sizeof(*di); |
472 | 473 | ||
473 | if (!(dl = kmalloc(size, GFP_KERNEL))) | 474 | dl = kmalloc(size, GFP_KERNEL); |
475 | if (!dl) | ||
474 | return -ENOMEM; | 476 | return -ENOMEM; |
475 | 477 | ||
476 | di = dl->dev_info; | 478 | di = dl->dev_info; |
@@ -513,7 +515,8 @@ static int rfcomm_get_dev_info(void __user *arg) | |||
513 | if (copy_from_user(&di, arg, sizeof(di))) | 515 | if (copy_from_user(&di, arg, sizeof(di))) |
514 | return -EFAULT; | 516 | return -EFAULT; |
515 | 517 | ||
516 | if (!(dev = rfcomm_dev_get(di.id))) | 518 | dev = rfcomm_dev_get(di.id); |
519 | if (!dev) | ||
517 | return -ENODEV; | 520 | return -ENODEV; |
518 | 521 | ||
519 | di.flags = dev->flags; | 522 | di.flags = dev->flags; |
@@ -561,7 +564,8 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb) | |||
561 | return; | 564 | return; |
562 | } | 565 | } |
563 | 566 | ||
564 | if (!(tty = dev->tty) || !skb_queue_empty(&dev->pending)) { | 567 | tty = dev->tty; |
568 | if (!tty || !skb_queue_empty(&dev->pending)) { | ||
565 | skb_queue_tail(&dev->pending, skb); | 569 | skb_queue_tail(&dev->pending, skb); |
566 | return; | 570 | return; |
567 | } | 571 | } |
@@ -796,7 +800,8 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in | |||
796 | 800 | ||
797 | memcpy(skb_put(skb, size), buf + sent, size); | 801 | memcpy(skb_put(skb, size), buf + sent, size); |
798 | 802 | ||
799 | if ((err = rfcomm_dlc_send(dlc, skb)) < 0) { | 803 | err = rfcomm_dlc_send(dlc, skb); |
804 | if (err < 0) { | ||
800 | kfree_skb(skb); | 805 | kfree_skb(skb); |
801 | break; | 806 | break; |
802 | } | 807 | } |
@@ -892,7 +897,7 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
892 | 897 | ||
893 | /* Parity on/off and when on, odd/even */ | 898 | /* Parity on/off and when on, odd/even */ |
894 | if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) || | 899 | if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) || |
895 | ((old->c_cflag & PARODD) != (new->c_cflag & PARODD)) ) { | 900 | ((old->c_cflag & PARODD) != (new->c_cflag & PARODD))) { |
896 | changes |= RFCOMM_RPN_PM_PARITY; | 901 | changes |= RFCOMM_RPN_PM_PARITY; |
897 | BT_DBG("Parity change detected."); | 902 | BT_DBG("Parity change detected."); |
898 | } | 903 | } |
@@ -937,11 +942,10 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
937 | /* POSIX does not support 1.5 stop bits and RFCOMM does not | 942 | /* POSIX does not support 1.5 stop bits and RFCOMM does not |
938 | * support 2 stop bits. So a request for 2 stop bits gets | 943 | * support 2 stop bits. So a request for 2 stop bits gets |
939 | * translated to 1.5 stop bits */ | 944 | * translated to 1.5 stop bits */ |
940 | if (new->c_cflag & CSTOPB) { | 945 | if (new->c_cflag & CSTOPB) |
941 | stop_bits = RFCOMM_RPN_STOP_15; | 946 | stop_bits = RFCOMM_RPN_STOP_15; |
942 | } else { | 947 | else |
943 | stop_bits = RFCOMM_RPN_STOP_1; | 948 | stop_bits = RFCOMM_RPN_STOP_1; |
944 | } | ||
945 | 949 | ||
946 | /* Handle number of data bits [5-8] */ | 950 | /* Handle number of data bits [5-8] */ |
947 | if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE)) | 951 | if ((old->c_cflag & CSIZE) != (new->c_cflag & CSIZE)) |