Skip to content

Commit f85e0c5

Browse files
jhovoldgregkh
authored andcommitted
Bluetooth: hci_intel: add missing tty-device sanity check
commit dcb9cfaa5ea9aa0ec08aeb92582ccfe3e4c719a9 upstream. Make sure to check the tty-device pointer before looking up the sibling platform device to avoid dereferencing a NULL-pointer when the tty is one end of a Unix98 pty. Fixes: 74cdad3 ("Bluetooth: hci_intel: Add runtime PM support") Fixes: 1ab1f23 ("Bluetooth: hci_intel: Add support for platform driver") Cc: Loic Poulain <loic.poulain@intel.com> Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf3feec commit f85e0c5

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

drivers/bluetooth/hci_intel.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ static int intel_set_power(struct hci_uart *hu, bool powered)
307307
struct list_head *p;
308308
int err = -ENODEV;
309309

310+
if (!hu->tty->dev)
311+
return err;
312+
310313
mutex_lock(&intel_device_list_lock);
311314

312315
list_for_each(p, &intel_device_list) {
@@ -379,6 +382,9 @@ static void intel_busy_work(struct work_struct *work)
379382
struct intel_data *intel = container_of(work, struct intel_data,
380383
busy_work);
381384

385+
if (!intel->hu->tty->dev)
386+
return;
387+
382388
/* Link is busy, delay the suspend */
383389
mutex_lock(&intel_device_list_lock);
384390
list_for_each(p, &intel_device_list) {
@@ -913,6 +919,8 @@ static int intel_setup(struct hci_uart *hu)
913919
list_for_each(p, &intel_device_list) {
914920
struct intel_device *dev = list_entry(p, struct intel_device,
915921
list);
922+
if (!hu->tty->dev)
923+
break;
916924
if (hu->tty->dev->parent == dev->pdev->dev.parent) {
917925
if (device_may_wakeup(&dev->pdev->dev))
918926
idev = dev;
@@ -1094,6 +1102,9 @@ static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb)
10941102

10951103
BT_DBG("hu %p skb %p", hu, skb);
10961104

1105+
if (!hu->tty->dev)
1106+
goto out_enqueue;
1107+
10971108
/* Be sure our controller is resumed and potential LPM transaction
10981109
* completed before enqueuing any packet.
10991110
*/
@@ -1110,7 +1121,7 @@ static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb)
11101121
}
11111122
}
11121123
mutex_unlock(&intel_device_list_lock);
1113-
1124+
out_enqueue:
11141125
skb_queue_tail(&intel->txq, skb);
11151126

11161127
return 0;

0 commit comments

Comments
 (0)