2019-03-13 23:54:43

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH] 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")
Reported-by: Balakrishna Godavarthi <[email protected]>
Reported-by: Rocky Liao <[email protected]>
Signed-off-by: Matthias Kaehlcke <[email protected]>
---
drivers/bluetooth/hci_qca.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 4ea995d610d2..714a6a16f9d5 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1004,7 +1004,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 */
--
2.21.0.360.g471c308f928-goog


2019-03-22 04:56:14

by Rocky Liao

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_qca: Fix crash with non-serdev devices

在 2019-03-14 07:52,Matthias Kaehlcke 写道:
> 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")
> Reported-by: Balakrishna Godavarthi <[email protected]>
> Reported-by: Rocky Liao <[email protected]>
> Signed-off-by: Matthias Kaehlcke <[email protected]>
> ---
> drivers/bluetooth/hci_qca.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 4ea995d610d2..714a6a16f9d5 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1004,7 +1004,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 */
Reviewed-by: Rocky Liao <[email protected]>
Tested-by: Rocky Liao <[email protected]>

2019-04-01 07:43:04

by Balakrishna Godavarthi

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_qca: Fix crash with non-serdev devices

On 2019-03-14 05:22, Matthias Kaehlcke wrote:
> 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")
> Reported-by: Balakrishna Godavarthi <[email protected]>
> Reported-by: Rocky Liao <[email protected]>
> Signed-off-by: Matthias Kaehlcke <[email protected]>
> ---
> drivers/bluetooth/hci_qca.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 4ea995d610d2..714a6a16f9d5 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1004,7 +1004,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 */

Reviewed-by: Balakrishna Godavarthi <[email protected]>

--
Regards
Balakrishna.

2019-04-01 21:37:37

by Matthias Kaehlcke

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: hci_qca: Fix crash with non-serdev devices

Hi Marcel,

do you have any comments or can this fix be landed?

Thanks

Matthias

On Wed, Mar 13, 2019 at 04:52:19PM -0700, Matthias Kaehlcke wrote:
> 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")
> Reported-by: Balakrishna Godavarthi <[email protected]>
> Reported-by: Rocky Liao <[email protected]>
> Signed-off-by: Matthias Kaehlcke <[email protected]>
> ---
> drivers/bluetooth/hci_qca.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 4ea995d610d2..714a6a16f9d5 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1004,7 +1004,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 */