Skip to content

Commit 412fe29

Browse files
jwrdegoedeholtmann
authored andcommitted
Bluetooth: hci_uart: Restore hci_dev->flush callback on open()
For reasons explained in detail in commit 3611f4d ("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>
1 parent c2e7f5d commit 412fe29

2 files changed

Lines changed: 22 additions & 17 deletions

File tree

‎drivers/bluetooth/hci_ldisc.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,6 @@ int hci_uart_init_ready(struct hci_uart *hu)
229229
}
230230

231231
/* ------- Interface to HCI layer ------ */
232-
/* Initialize device */
233-
static int hci_uart_open(struct hci_dev *hdev)
234-
{
235-
BT_DBG("%s %p", hdev->name, hdev);
236-
237-
/* Nothing to do for UART driver */
238-
return 0;
239-
}
240-
241232
/* Reset device */
242233
static int hci_uart_flush(struct hci_dev *hdev)
243234
{
@@ -264,6 +255,17 @@ static int hci_uart_flush(struct hci_dev *hdev)
264255
return 0;
265256
}
266257

258+
/* Initialize device */
259+
static int hci_uart_open(struct hci_dev *hdev)
260+
{
261+
BT_DBG("%s %p", hdev->name, hdev);
262+
263+
/* Undo clearing this from hci_uart_close() */
264+
hdev->flush = hci_uart_flush;
265+
266+
return 0;
267+
}
268+
267269
/* Close device */
268270
static int hci_uart_close(struct hci_dev *hdev)
269271
{

‎drivers/bluetooth/hci_serdev.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,6 @@ static void hci_uart_write_work(struct work_struct *work)
101101

102102
/* ------- Interface to HCI layer ------ */
103103

104-
/* Initialize device */
105-
static int hci_uart_open(struct hci_dev *hdev)
106-
{
107-
BT_DBG("%s %p", hdev->name, hdev);
108-
109-
return 0;
110-
}
111-
112104
/* Reset device */
113105
static int hci_uart_flush(struct hci_dev *hdev)
114106
{
@@ -129,6 +121,17 @@ static int hci_uart_flush(struct hci_dev *hdev)
129121
return 0;
130122
}
131123

124+
/* Initialize device */
125+
static int hci_uart_open(struct hci_dev *hdev)
126+
{
127+
BT_DBG("%s %p", hdev->name, hdev);
128+
129+
/* Undo clearing this from hci_uart_close() */
130+
hdev->flush = hci_uart_flush;
131+
132+
return 0;
133+
}
134+
132135
/* Close device */
133136
static int hci_uart_close(struct hci_dev *hdev)
134137
{

0 commit comments

Comments
 (0)