Skip to contentSkip to conversation

Bluetooth: hci_qca: Fix crash with non-serdev devices

PATCH In review Matthias Kaehlcke 2 participants 2 messages Apr 23, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_qca: Fix crash with non-serdev devices

qca_set_baudrate() calls serdev_device_wait_until_sent() assuming that the HCI is always associated with a serdev device. This isn't true for ROME controllers instantiated through ldisc, where the call causes a crash due to a NULL pointer dereferentiation. Only call the function when we have a serdev device. The timeout for ROME devices at the end of qca_set_baudrate() is long enough to be reasonably sure that the command was sent.

Fixes fa9ad876b8e0 ("Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990")

---
Changes in v2:
- first version got corrupted for some reason, this should apply
- added 'Reviewed-by' tags from Rocky abd Balakrishna
- added 'Tested-by' tag from Rocky

---
 drivers/bluetooth/hci_qca.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +2 -1
index a80c3bc90904..7f75652686fe 100644
@@ -1006,7 +1006,8 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	while (!skb_queue_empty(&qca->txq))
 		usleep_range(100, 200);
 
-	serdev_device_wait_until_sent(hu->serdev,
+	if (hu->serdev)
+		serdev_device_wait_until_sent(hu->serdev,
 		      msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
 
 	/* Give the controller time to process the request */
Signature · 1 line
2.21.0.593.g511ec345e18-goog
maintainer
#1 lore raw

Hi Matthias,

Quoted 15 lines

qca_set_baudrate() calls serdev_device_wait_until_sent() assuming that the HCI is always associated with a serdev device. This isn't true for ROME controllers instantiated through ldisc, where the call causes a crash due to a NULL pointer dereferentiation. Only call the function when we have a serdev device. The timeout for ROME devices at the end of qca_set_baudrate() is long enough to be reasonably sure that the command was sent.

Fixes fa9ad876b8e0 ("Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990")
Quoted 8 lines

---
Changes in v2:
- first version got corrupted for some reason, this should apply
- added 'Reviewed-by' tags from Rocky abd Balakrishna
- added 'Tested-by' tag from Rocky
---
drivers/bluetooth/hci_qca.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel