All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zijun Hu <quic_zijuhu@quicinc.com>
To: <luiz.dentz@gmail.com>, <luiz.von.dentz@intel.com>,
	<marcel@holtmann.org>
Cc: <linux-bluetooth@vger.kernel.org>, <quic_zijuhu@quicinc.com>
Subject: [PATCH v3 1/4] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME
Date: Thu, 18 Apr 2024 11:11:50 +0800	[thread overview]
Message-ID: <1713409913-13042-2-git-send-email-quic_zijuhu@quicinc.com> (raw)
In-Reply-To: <1713409913-13042-1-git-send-email-quic_zijuhu@quicinc.com>

A kernel crash will happen when use tool btattach for a BT controller
with soc type QCA_ROME, and it is caused by dereferencing nullptr
hu->serdev, fixed by null check before access.

sudo btattach -B /dev/ttyUSB0 -P qca
Bluetooth: hci1: QCA setup on UART is completed
BUG: kernel NULL pointer dereference, address: 00000000000002f0
......
Workqueue: hci1 hci_power_on [bluetooth]
RIP: 0010:qca_setup+0x7c1/0xe30 [hci_uart]
......
Call Trace:
 <TASK>
 ? show_regs+0x72/0x90
 ? __die+0x25/0x80
 ? page_fault_oops+0x154/0x4c0
 ? srso_alias_return_thunk+0x5/0xfbef5
 ? kmem_cache_alloc+0x16b/0x310
 ? do_user_addr_fault+0x330/0x6e0
 ? srso_alias_return_thunk+0x5/0xfbef5
 ? exc_page_fault+0x84/0x1b0
 ? asm_exc_page_fault+0x27/0x30
 ? qca_setup+0x7c1/0xe30 [hci_uart]
 hci_uart_setup+0x5c/0x1a0 [hci_uart]
 hci_dev_open_sync+0xee/0xca0 [bluetooth]
 hci_dev_do_open+0x2a/0x70 [bluetooth]
 hci_power_on+0x46/0x210 [bluetooth]
 process_one_work+0x17b/0x360
 worker_thread+0x307/0x430
 ? __pfx_worker_thread+0x10/0x10
 kthread+0xf7/0x130
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x46/0x70
 ? __pfx_kthread+0x10/0x10
 ret_from_fork_asm+0x1b/0x30
 </TASK>

Fixes: 03b0093f7b31 ("Bluetooth: hci_qca: get wakeup status from serdev device handle")
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Tested-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/bluetooth/hci_qca.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 92fa20f5ac7d..fdaf83d817af 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1955,7 +1955,7 @@ static int qca_setup(struct hci_uart *hu)
 		qca_debugfs_init(hdev);
 		hu->hdev->hw_error = qca_hw_error;
 		hu->hdev->cmd_timeout = qca_cmd_timeout;
-		if (device_can_wakeup(hu->serdev->ctrl->dev.parent))
+		if (hu->serdev && device_can_wakeup(hu->serdev->ctrl->dev.parent))
 			hu->hdev->wakeup = qca_wakeup;
 	} else if (ret == -ENOENT) {
 		/* No patch/nvm-config found, run with original fw/config */
-- 
2.7.4


  reply	other threads:[~2024-04-18  3:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20  6:08 [PATCH v1 0/2] Bluetooth: qca: Add tool btattach support for more QCA soc types Zijun Hu
2024-03-20  6:08 ` [PATCH v1 1/2] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-03-20  6:34   ` Bluetooth: qca: Add tool btattach support for more QCA soc types bluez.test.bot
2024-03-20  6:08 ` [PATCH v1 2/2] Bluetooth: qca: Fix wrong soc_type returned for tool btattach Zijun Hu
2024-03-20  7:19 ` [PATCH v1] tools/btattach: Add support for all QCA soc_types Zijun Hu
2024-03-20  9:02   ` [v1] " bluez.test.bot
2024-04-12 16:26 ` [PATCH v1 0/3] Fix 2 tool btattach issues for QCA controllers Zijun Hu
2024-04-12 16:26   ` [PATCH v1 1/3] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME Zijun Hu
2024-04-12 16:56     ` Fix 2 tool btattach issues for QCA controllers bluez.test.bot
2024-04-12 16:26   ` [PATCH v1 2/3] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-04-12 16:26   ` [PATCH v1 3/3] Bluetooth: qca: Fix wrong soc type returned for tool btattach Zijun Hu
2024-04-12 16:26   ` [PATCH BlueZ v1] tools/btattach: Add support for more QCA soc types Zijun Hu
2024-04-12 18:02     ` [BlueZ,v1] " bluez.test.bot
2024-04-12 20:10     ` [PATCH BlueZ v1] " Wren Turkal
2024-04-13  2:44       ` quic_zijuhu
2024-04-13  3:12         ` Wren Turkal
2024-04-18  3:38     ` [PATCH BlueZ v2] " Zijun Hu
2024-04-18  5:40       ` [BlueZ,v2] " bluez.test.bot
2024-04-17 12:52 ` [PATCH v2 0/4] Fix 2 tool btattach issues for QCA controllers Zijun Hu
2024-04-17 12:52   ` [PATCH v2 1/4] Bluetooth: qca: Fix crash caused by tool btattach for QCA_ROME Zijun Hu
2024-04-17 12:52   ` [PATCH v2 2/4] Bluetooth: qca: Fix nullptr dereference for non-serdev devices Zijun Hu
2024-04-17 12:52   ` [PATCH v2 3/4] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-04-17 21:27     ` Luiz Augusto von Dentz
2024-04-18  0:44       ` quic_zijuhu
2024-04-17 12:52   ` [PATCH v2 4/4] Bluetooth: qca: Fix wrong soc type returned for tool btattach Zijun Hu
2024-04-17 21:39     ` Luiz Augusto von Dentz
2024-04-18  1:26       ` quic_zijuhu
2024-04-18  3:11   ` [PATCH v3 0/4] Fix 2 tool btattach issues for QCA controllers Zijun Hu
2024-04-18  3:11     ` Zijun Hu [this message]
2024-04-18  3:57       ` bluez.test.bot
2024-04-18  3:11     ` [PATCH v3 2/4] Bluetooth: qca: Fix nullptr dereference for non-serdev devices Zijun Hu
2024-04-18 16:08       ` Johan Hovold
2024-04-18 22:15         ` quic_zijuhu
2024-04-18  3:11     ` [PATCH v3 3/4] Bluetooth: hci_ldisc: Add a ioctl HCIUARTSETPROTODATA Zijun Hu
2024-04-18  3:11     ` [PATCH v3 4/4] Bluetooth: qca: Support more soc types for non-serdev devices Zijun Hu

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=1713409913-13042-2-git-send-email-quic_zijuhu@quicinc.com \
    --to=quic_zijuhu@quicinc.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=luiz.von.dentz@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.