Linux bluetooth development
 help / color / mirror / Atom feed
From: rabindra789 <rabindrameher116@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: Pauli Virtanen <pav@iki.fi>, Chengfeng Ye <nicoyip.dev@gmail.com>,
	linux-bluetooth@vger.kernel.org,
	rabindra789 <rabindrameher116@gmail.com>,
	syzbot+48fc5b35b350240fd465@syzkaller.appspotmail.com
Subject: [PATCH] Bluetooth: hci_sync: Cancel cmd_timer before draining workqueue
Date: Fri,  2 Oct 2026 04:48:09 +0000	[thread overview]
Message-ID: <20261002044810.80340-1-rabindrameher116@gmail.com> (raw)

cmd_timer can expire while hdev->workqueue is being drained,
causing hci_cmd_timeout to be queued on a draining workqueue.

Cancel cmd_timer before draining the workqueue.

Reported-by: syzbot+48fc5b35b350240fd465@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=48fc5b35b350240fd465
Fixes: 40b87657200c ("Bluetooth: hci_core: Rework hci_dev_do_reset() to use hci_sync functions")

Signed-off-by: rabindra789 <rabindrameher116@gmail.com>
---
 net/bluetooth/hci_sync.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index c01c8b58d9e8..e1c28bffdc15 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -5545,6 +5545,8 @@ int hci_dev_close_sync(struct hci_dev *hdev)
 	 */
 	hci_dev_set_flag(hdev, HCI_CMD_DRAIN_WORKQUEUE);
 	synchronize_rcu();
+	/* Explicitly cancel works in case scheduled after setting the flag. */
+	cancel_delayed_work_sync(&hdev->cmd_timer);
 
 	if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
 		disable_delayed_work(&hdev->power_off);
-- 
2.43.0


             reply	other threads:[~2026-10-02  4:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02  4:48 rabindra789 [this message]
2026-10-02  9:42 ` Bluetooth: hci_sync: Cancel cmd_timer before draining workqueue bluez.test.bot
2026-10-02 14:29 ` [PATCH] " Luiz Augusto von Dentz
2026-10-02 14:32   ` Luiz Augusto von Dentz
     [not found]     ` <CAOa02aN_YgSB7L6eG-+Og3dx103kZpoRy1Ho27aMvo2dsoQCVw@mail.gmail.com>
2026-10-03 11:25       ` Rabindra Kumar Meher

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=20261002044810.80340-1-rabindrameher116@gmail.com \
    --to=rabindrameher116@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=nicoyip.dev@gmail.com \
    --cc=pav@iki.fi \
    --cc=syzbot+48fc5b35b350240fd465@syzkaller.appspotmail.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