]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: hci_uart: Restore hci_dev->flush callback on open()
authorHans de Goede <hdegoede@redhat.com>
Sun, 27 May 2018 19:04:51 +0000 (21:04 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 30 May 2018 06:46:17 +0000 (08:46 +0200)
For reasons explained in detail in commit 3611f4d2a5e0 ("hci_ldisc:
fix null pointer deref") the hci_uart_close() functions sets
hci_dev->flush to NULL.

But the device may be re-opened after a close, this commit restores the
hci_dev->flush callback on open().

Note this commit also moves the nearly empty defition of hci_uart_open()
a bit down in the file to avoid the need for forward declaring
hci_uart_flush().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_ldisc.c
drivers/bluetooth/hci_serdev.c

index 954213e5daa518fdb792aa2a08dd0ebeed2dea51..1c49964f5e601011fbec5a411ff13dad1de91459 100644 (file)
@@ -229,15 +229,6 @@ int hci_uart_init_ready(struct hci_uart *hu)
 }
 
 /* ------- Interface to HCI layer ------ */
-/* Initialize device */
-static int hci_uart_open(struct hci_dev *hdev)
-{
-       BT_DBG("%s %p", hdev->name, hdev);
-
-       /* Nothing to do for UART driver */
-       return 0;
-}
-
 /* Reset device */
 static int hci_uart_flush(struct hci_dev *hdev)
 {
@@ -264,6 +255,17 @@ static int hci_uart_flush(struct hci_dev *hdev)
        return 0;
 }
 
+/* Initialize device */
+static int hci_uart_open(struct hci_dev *hdev)
+{
+       BT_DBG("%s %p", hdev->name, hdev);
+
+       /* Undo clearing this from hci_uart_close() */
+       hdev->flush = hci_uart_flush;
+
+       return 0;
+}
+
 /* Close device */
 static int hci_uart_close(struct hci_dev *hdev)
 {
index a0e939856568f1275108e2f7939868a663e496a1..6a713f13f71ccef103373ae8a00e6f1821c32564 100644 (file)
@@ -101,14 +101,6 @@ static void hci_uart_write_work(struct work_struct *work)
 
 /* ------- Interface to HCI layer ------ */
 
-/* Initialize device */
-static int hci_uart_open(struct hci_dev *hdev)
-{
-       BT_DBG("%s %p", hdev->name, hdev);
-
-       return 0;
-}
-
 /* Reset device */
 static int hci_uart_flush(struct hci_dev *hdev)
 {
@@ -129,6 +121,17 @@ static int hci_uart_flush(struct hci_dev *hdev)
        return 0;
 }
 
+/* Initialize device */
+static int hci_uart_open(struct hci_dev *hdev)
+{
+       BT_DBG("%s %p", hdev->name, hdev);
+
+       /* Undo clearing this from hci_uart_close() */
+       hdev->flush = hci_uart_flush;
+
+       return 0;
+}
+
 /* Close device */
 static int hci_uart_close(struct hci_dev *hdev)
 {