Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: drop the pending command if the adv monitor queue fails
@ 2026-11-04  2:28 Wentao Liang
  2026-11-04  7:12 ` Krzysztof Kozlowski
  2026-11-04  8:39 ` bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-04  2:28 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz; +Cc: linux-bluetooth

__add_adv_patterns_monitor() links the command into hdev->mgmt_pending,
which takes a reference on the socket, and then queues the sync work.
When hci_cmd_sync_queue() fails, for example because the controller is
not running or is being unregistered, the work never runs and the
completion callback that would free the command is never invoked. The
command therefore stays on the pending list and keeps the socket
reference until the controller is unregistered, and it also keeps
MGMT_OP_ADD_ADV_PATTERNS_MONITOR busy for other requests.

Remove the pending command on the queue failure path, matching what the
other management commands do when their queueing fails.

Fixes: b747a83690c8 ("Bluetooth: hci_sync: Refactor add Adv Monitor")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 net/bluetooth/mgmt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 3b9c82bd2f02..282ce65f19eb 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -5542,6 +5542,7 @@ static int __add_adv_patterns_monitor(struct sock *sk, struct hci_dev *hdev,
 		else
 			status = MGMT_STATUS_FAILED;
 
+		mgmt_pending_remove(cmd);
 		goto unlock;
 	}
 
-- 
2.34.1


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

end of thread, other threads:[~2026-11-04  8:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:28 [PATCH] Bluetooth: drop the pending command if the adv monitor queue fails Wentao Liang
2026-11-04  7:12 ` Krzysztof Kozlowski
2026-11-04  8:39 ` 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