mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: hci_sync: clear cmd_sync_work_list when power off
@ 2024-11-25 17:51 Jiayang Mao
  2024-12-02 20:41 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 7+ messages in thread
From: Jiayang Mao @ 2024-11-25 17:51 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, quic_chejiang, quic_jiaymao

Clear the remaining command in cmd_sync_work_list when BT is
performing power off. In some cases, this list is not empty after
power off. BT host will try to send more HCI commands.
This can cause unexpected results.

Signed-off-by: Jiayang Mao <quic_jiaymao@quicinc.com>
---
 net/bluetooth/hci_sync.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index c86f4e42e..bc622d074 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5139,6 +5139,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)
 {
 	bool auto_off;
 	int err = 0;
+	struct hci_cmd_sync_work_entry *entry, *tmp;
 
 	bt_dev_dbg(hdev, "");
 
@@ -5258,6 +5259,11 @@ int hci_dev_close_sync(struct hci_dev *hdev)
 	clear_bit(HCI_RUNNING, &hdev->flags);
 	hci_sock_dev_event(hdev, HCI_DEV_CLOSE);
 
+	mutex_lock(&hdev->cmd_sync_work_lock);
+	list_for_each_entry_safe(entry, tmp, &hdev->cmd_sync_work_list, list)
+		_hci_cmd_sync_cancel_entry(hdev, entry, -ECANCELED);
+	mutex_unlock(&hdev->cmd_sync_work_lock);
+
 	/* After this point our queues are empty and no tasks are scheduled. */
 	hdev->close(hdev);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-12-16 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 17:51 [PATCH v1] Bluetooth: hci_sync: clear cmd_sync_work_list when power off Jiayang Mao
2024-12-02 20:41 ` Luiz Augusto von Dentz
2024-12-03 17:19   ` Jiayang Mao
2024-12-03 17:28     ` Luiz Augusto von Dentz
2024-12-04 13:47       ` Jiayang Mao
2024-12-16 13:35         ` Jiayang Mao
2024-12-16 14:56           ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®