From: <gregkh@linuxfoundation.org>
To: enderaoelyther@gmail.com,luiz.von.dentz@intel.com
Cc: <stable@vger.kernel.org>
Subject: FAILED: patch "[PATCH] Bluetooth: hci_serdev: serialize flush with transmit work" failed to apply to 6.18-stable tree
Date: Wed, 02 Dec 2026 13:59:03 +0100 [thread overview]
Message-ID: <2026120203-overreact-denatured-40ea@gregkh> (raw)
The patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x ee43bade37c4578b52a76cf0cdb199d3c0019506
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120203-overreact-denatured-40ea@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ee43bade37c4578b52a76cf0cdb199d3c0019506 Mon Sep 17 00:00:00 2001
From: Zhao Li <enderaoelyther@gmail.com>
Date: Mon, 16 Nov 2026 16:05:38 +0800
Subject: [PATCH] Bluetooth: hci_serdev: serialize flush with transmit work
hci_uart_flush() runs on HCI close and reset and frees hu->tx_skb while
write_work may still be sending the same partial frame. The worker can
then resume with a freed skb, or both paths can free the frame.
The tty flush has stopped write_work before freeing the partial frame
since commit 1b0d946d6f08 ("Bluetooth: hci_uart: clear HCI_UART_SENDING
when write_work is canceled"). Do the same in the serdev flush: disable
and drain write_work before releasing the frame, and hold
HCI_UART_SENDING meanwhile so that hci_uart_tx_wakeup() only records
HCI_UART_TX_WAKEUP. Then re-enable the work, release SENDING and replay
a wakeup that arrived in between.
AI assistance was used.
Fixes: 82f5169bf3d3 ("Bluetooth: hci_uart: add serdev driver support library")
Cc: stable@vger.kernel.org # needs adjustments for <= 7.4
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
index d2c48df34199..194f11251cc5 100644
--- a/drivers/bluetooth/hci_serdev.c
+++ b/drivers/bluetooth/hci_serdev.c
@@ -97,17 +97,26 @@ static int hci_uart_flush(struct hci_dev *hdev)
BT_DBG("hdev %p serdev %p", hdev, hu->serdev);
+ /* Stop write_work and hold SENDING so wakeups only set TX_WAKEUP. */
+ disable_work_sync(&hu->write_work);
+ set_bit(HCI_UART_SENDING, &hu->tx_state);
+
if (hu->tx_skb) {
kfree_skb(hu->tx_skb); hu->tx_skb = NULL;
}
- if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
- return 0;
+ if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+ /* Flush any pending characters in the driver and discipline. */
+ serdev_device_write_flush(hu->serdev);
- /* Flush any pending characters in the driver and discipline. */
- serdev_device_write_flush(hu->serdev);
+ hu->proto->flush(hu);
+ }
- hu->proto->flush(hu);
+ /* Resume TX and replay a wakeup recorded while it was stopped. */
+ enable_work(&hu->write_work);
+ clear_bit(HCI_UART_SENDING, &hu->tx_state);
+ if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state))
+ hci_uart_tx_wakeup(hu);
return 0;
}
reply other threads:[~2026-12-02 14:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2026120203-overreact-denatured-40ea@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=enderaoelyther@gmail.com \
--cc=luiz.von.dentz@intel.com \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox