All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] Bluetooth: hci_serdev: serialize flush with transmit work" failed to apply to 6.18-stable tree
@ 2026-12-02 12:59 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2026-12-02 12:59 UTC (permalink / raw)
  To: enderaoelyther, luiz.von.dentz; +Cc: stable


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;
 }


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02 14:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:59 FAILED: patch "[PATCH] Bluetooth: hci_serdev: serialize flush with transmit work" failed to apply to 6.18-stable tree gregkh

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.