From: Johan Hovold <johan@kernel.org>
To: Zijun Hu <quic_zijuhu@quicinc.com>
Cc: luiz.dentz@gmail.com, marcel@holtmann.org,
linux-bluetooth@vger.kernel.org, johan+linaro@kernel.org
Subject: Re: [PATCH] Bluetooth: qca: Fix nullptr dereference for non-serdev devices
Date: Wed, 17 Apr 2024 08:30:00 +0200 [thread overview]
Message-ID: <Zh9saGbOl-fXP6SD@hovoldconsulting.com> (raw)
In-Reply-To: <1713325792-17181-1-git-send-email-quic_zijuhu@quicinc.com>
On Wed, Apr 17, 2024 at 11:49:52AM +0800, Zijun Hu wrote:
> hu->serdev is nullptr and will cause nullptr dereference if qca_setup()
> is called by non-serdev device, fixed by null check before access.
No, this patch is not correct.
> 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);
Non-serdev controllers have type QCA_ROME (see qca_soc_type()) so will
never end up in this path.
I verified this when I wrote the patch and also fixed up a couple of
real non-serdev bugs here:
https://lore.kernel.org/lkml/20240319154611.2492-1-johan+linaro@kernel.org/
> - 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);
Johan
next prev parent reply other threads:[~2024-04-17 6:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 3:49 [PATCH] Bluetooth: qca: Fix nullptr dereference for non-serdev devices Zijun Hu
2024-04-17 4:34 ` bluez.test.bot
2024-04-17 6:30 ` Johan Hovold [this message]
2024-04-17 6:51 ` [PATCH] " 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=Zh9saGbOl-fXP6SD@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=johan+linaro@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=quic_zijuhu@quicinc.com \
/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