linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zijun Hu <quic_zijuhu@quicinc.com>
To: <luiz.dentz@gmail.com>, <marcel@holtmann.org>
Cc: <quic_zijuhu@quicinc.com>, <linux-bluetooth@vger.kernel.org>,
	<johan+linaro@kernel.org>
Subject: [PATCH] Bluetooth: qca: Fix nullptr dereference for non-serdev devices
Date: Wed, 17 Apr 2024 11:49:52 +0800	[thread overview]
Message-ID: <1713325792-17181-1-git-send-email-quic_zijuhu@quicinc.com> (raw)

hu->serdev is nullptr and will cause nullptr dereference if qca_setup()
is called by non-serdev device, fixed by null check before access.

Fixes: 77f45cca8bc5 ("Bluetooth: qca: fix device-address endianness")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/bluetooth/hci_qca.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 92fa20f5ac7d..9c6573c727e1 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1905,10 +1905,11 @@ static int qca_setup(struct hci_uart *hu)
 	case QCA_WCN6750:
 	case QCA_WCN6855:
 	case QCA_WCN7850:
-		qcadev = serdev_device_get_drvdata(hu->serdev);
-		if (qcadev->bdaddr_property_broken)
-			set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks);
-
+		if (hu->serdev) {
+			qcadev = serdev_device_get_drvdata(hu->serdev);
+			if (qcadev->bdaddr_property_broken)
+				set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks);
+		}
 		hci_set_aosp_capable(hdev);
 
 		ret = qca_read_soc_version(hdev, &ver, soc_type);
-- 
2.7.4


             reply	other threads:[~2024-04-17  3:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17  3:49 Zijun Hu [this message]
2024-04-17  4:34 ` Bluetooth: qca: Fix nullptr dereference for non-serdev devices bluez.test.bot
2024-04-17  6:30 ` [PATCH] " Johan Hovold
2024-04-17  6:51   ` quic_zijuhu
2024-04-17  7:10     ` Johan Hovold
2024-04-17  7:32       ` quic_zijuhu
2024-04-17  8:32         ` Johan Hovold
2024-04-17  9:38           ` quic_zijuhu
2024-04-17  9:41             ` quic_zijuhu
2024-04-18 15:59             ` Johan Hovold
2024-04-18 17:07               ` Luiz Augusto von Dentz
2024-04-18 23:04               ` quic_zijuhu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1713325792-17181-1-git-send-email-quic_zijuhu@quicinc.com \
    --to=quic_zijuhu@quicinc.com \
    --cc=johan+linaro@kernel.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).