OSDN Git Service

Bluetooth: hci_ldisc: Fix another race when closing the tty.
authorRonald Tschalär <ronald@innovation.ch>
Thu, 26 Oct 2017 05:15:19 +0000 (22:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2017 09:10:29 +0000 (10:10 +0100)
commite508e6026b198b9879e0d1850fdef8ef1d4d0805
treec0f8fb6c5080736e3f42b2a699f8f31fcd2b81d0
parent7d1beb462e18b55fa5d0990d0f60fbf4edfda61b
Bluetooth: hci_ldisc: Fix another race when closing the tty.

[ Upstream commit 0338b1b393ec7910898e8f7b25b3bf31a7282e16 ]

The following race condition still existed:

         P1                                P2
  cancel_work_sync()
                                     hci_uart_tx_wakeup()
                                     hci_uart_write_work()
                                     hci_uart_dequeue()
  clear_bit(HCI_UART_PROTO_READY)
  hci_unregister_dev(hdev)
  hci_free_dev(hdev)
  hu->proto->close(hu)
  kfree(hu)
                                     access to hdev and hu

Cancelling the work after clearing the HCI_UART_PROTO_READY bit avoids
this as any hci_uart_tx_wakeup() issued after the flag is cleared will
detect that and not schedule further work.

Signed-off-by: Ronald Tschalär <ronald@innovation.ch>
Reviewed-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bluetooth/hci_ldisc.c