* [PATCH] Bluetooth: hci_serdev: stop write_work before closing the port
@ 2026-11-18 12:48 Zhao Li
2026-11-18 18:48 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Zhao Li @ 2026-11-18 12:48 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Venkata Lakshmi Narayana Gubba, linux-bluetooth, linux-kernel,
stable, Zhao Li
With HCI_QUIRK_NON_PERSISTENT_SETUP, hci_uart_close() clears
HCI_UART_PROTO_READY without hu->proto_lock and closes the serdev port
without waiting for write_work. The hci_uart_flush() just before it
re-enables write_work and may replay a recorded wakeup, and
hci_uart_tx_wakeup() queues it from any caller that passed the
HCI_UART_PROTO_READY test, such as the serdev write_wakeup callback.
write_work can then call ttyport_write_buf() while ttyport_close()
releases the tty, so it writes through a released tty.
A partial frame that write_work leaves in hu->tx_skb also survives into
the next open, which flushes nothing, and would be sent first to the
controller after it is powered on again.
Quiesce the transmit path as hci_uart_unregister_device() does: clear
HCI_UART_PROTO_READY under percpu_down_write() so that no wakeup is in
flight, cancel write_work, free the leftover frame, then close the port.
Found by code review. Compile-tested with W=1.
AI assistance was used.
Fixes: de8892df72be ("Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set")
Cc: stable@vger.kernel.org # needs adjustments for <= 6.12
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
No new W=1, sparse or smatch warnings.
drivers/bluetooth/hci_serdev.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
index 194f11251cc5..028f691bd7da 100644
--- a/drivers/bluetooth/hci_serdev.c
+++ b/drivers/bluetooth/hci_serdev.c
@@ -164,7 +164,18 @@ static int hci_uart_close(struct hci_dev *hdev)
* open may drain the battery.
*/
if (hci_test_quirk(hdev, HCI_QUIRK_NON_PERSISTENT_SETUP)) {
+ percpu_down_write(&hu->proto_lock);
clear_bit(HCI_UART_PROTO_READY, &hu->flags);
+ percpu_up_write(&hu->proto_lock);
+
+ cancel_work_sync(&hu->write_work);
+
+ /* Do not send a stale partial frame after the next open. */
+ if (hu->tx_skb) {
+ kfree_skb(hu->tx_skb);
+ hu->tx_skb = NULL;
+ }
+
serdev_device_close(hu->serdev);
}
base-commit: f42f5cae154b90a0cb6d8232dc84c7614ca2e6a0
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: Bluetooth: hci_serdev: stop write_work before closing the port
2026-11-18 12:48 [PATCH] Bluetooth: hci_serdev: stop write_work before closing the port Zhao Li
@ 2026-11-18 18:48 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-18 18:48 UTC (permalink / raw)
To: linux-bluetooth, enderaoelyther
[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1214977/
---Test result---
Test Summary:
CheckPatch PASS 0.57 seconds
VerifyFixes PASS 0.11 seconds
VerifySignedoff PASS 0.11 seconds
GitLint PASS 0.28 seconds
SubjectPrefix PASS 0.11 seconds
BuildKernel PASS 20.23 seconds
CheckAllWarning PASS 23.26 seconds
CheckSparse PASS 25.20 seconds
BuildKernel32 PASS 20.56 seconds
CheckKernelLLVM PASS 22.54 seconds
TestRunnerSetup PASS 490.48 seconds
IncrementalBuild PASS 20.12 seconds
https://github.com/bluez/bluetooth-next/pull/1150
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 18:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 12:48 [PATCH] Bluetooth: hci_serdev: stop write_work before closing the port Zhao Li
2026-11-18 18:48 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox