diff options
Diffstat (limited to 'drivers/bluetooth/hci_ldisc.c')
-rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 998833d93c13..48ad2a7ab080 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -101,7 +101,7 @@ static inline void hci_uart_tx_complete(struct hci_uart *hu, int pkt_type) | |||
101 | break; | 101 | break; |
102 | 102 | ||
103 | case HCI_SCODATA_PKT: | 103 | case HCI_SCODATA_PKT: |
104 | hdev->stat.cmd_tx++; | 104 | hdev->stat.sco_tx++; |
105 | break; | 105 | break; |
106 | } | 106 | } |
107 | } | 107 | } |
@@ -256,9 +256,16 @@ static int hci_uart_tty_open(struct tty_struct *tty) | |||
256 | 256 | ||
257 | BT_DBG("tty %p", tty); | 257 | BT_DBG("tty %p", tty); |
258 | 258 | ||
259 | /* FIXME: This btw is bogus, nothing requires the old ldisc to clear | ||
260 | the pointer */ | ||
259 | if (hu) | 261 | if (hu) |
260 | return -EEXIST; | 262 | return -EEXIST; |
261 | 263 | ||
264 | /* Error if the tty has no write op instead of leaving an exploitable | ||
265 | hole */ | ||
266 | if (tty->ops->write == NULL) | ||
267 | return -EOPNOTSUPP; | ||
268 | |||
262 | if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) { | 269 | if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) { |
263 | BT_ERR("Can't allocate control structure"); | 270 | BT_ERR("Can't allocate control structure"); |
264 | return -ENFILE; | 271 | return -ENFILE; |
@@ -304,8 +311,10 @@ static void hci_uart_tty_close(struct tty_struct *tty) | |||
304 | 311 | ||
305 | if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { | 312 | if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { |
306 | hu->proto->close(hu); | 313 | hu->proto->close(hu); |
307 | hci_unregister_dev(hdev); | 314 | if (hdev) { |
308 | hci_free_dev(hdev); | 315 | hci_unregister_dev(hdev); |
316 | hci_free_dev(hdev); | ||
317 | } | ||
309 | } | 318 | } |
310 | } | 319 | } |
311 | } | 320 | } |
@@ -389,6 +398,7 @@ static int hci_uart_register_dev(struct hci_uart *hu) | |||
389 | hdev->flush = hci_uart_flush; | 398 | hdev->flush = hci_uart_flush; |
390 | hdev->send = hci_uart_send_frame; | 399 | hdev->send = hci_uart_send_frame; |
391 | hdev->destruct = hci_uart_destruct; | 400 | hdev->destruct = hci_uart_destruct; |
401 | hdev->parent = hu->tty->dev; | ||
392 | 402 | ||
393 | hdev->owner = THIS_MODULE; | 403 | hdev->owner = THIS_MODULE; |
394 | 404 | ||