From: Dean Jenkins Date: Fri, 28 Apr 2017 12:57:24 +0000 (+0100) Subject: Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame() X-Git-Tag: v4.12-rc1~129^2~23^2~4 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=ab00f89fdff61975fa52a61608080ea7b8d8e800;p=karo-tx-linux.git Bluetooth: hci_ldisc: Add protocol check to hci_uart_send_frame() Before attempting to send a HCI message, check that the Data Link protocol is still bound to the HCI UART driver. This makes the code consistent with the usage of the other proto function pointers. Therefore, add a check for HCI_UART_PROTO_READY into hci_uart_send_frame() and return -EUNATCH if the Data Link protocol is not bound. This also allows hci_send_frame() to report the error of an unbound Data Link protocol layer. Therefore, it assists with diagnostics into why HCI messages are being sent when the Data Link protocol is not bound and avoids potential crashes. Signed-off-by: Dean Jenkins Signed-off-by: Marcel Holtmann --- diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index c53513cb7654..c515aa9b923c 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -256,6 +256,9 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb) BT_DBG("%s: type %d len %d", hdev->name, hci_skb_pkt_type(skb), skb->len); + if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) + return -EUNATCH; + hu->proto->enqueue(hu, skb); hci_uart_tx_wakeup(hu);