Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: free the mesh tx if queueing the send fails
@ 2026-11-04  2:28 Wentao Liang
  2026-11-04  7:12 ` Krzysztof Kozlowski
  2026-11-04  8:46 ` 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

mesh_send() puts the new mesh_tx on hdev->mesh_pending through
mgmt_mesh_add(), which takes a socket reference, and only then queues
mesh_send_sync(). The cleanup on the failure path is guarded by
"sending", but that flag is set from HCI_MESH_SENDING before the queueing
and err is only ever set when it is clear: when sending is set no queueing
happens and no error is recorded. The guard is therefore never true on the
error path, so a failure of hci_cmd_sync_queue() leaves the mesh_tx on the
list with its socket reference held and no worker to consume it.

Drop the stale guard and always release the mesh_tx when the request
cannot be queued.

Fixes: b338d91703fa ("Bluetooth: Implement support for Mesh")
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 | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 282ce65f19eb..067d4f5d961e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2544,10 +2544,8 @@ static int mesh_send(struct sock *sk, struct hci_dev *hdev, void *data, u16 len)
 		err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_MESH_SEND,
 				      MGMT_STATUS_FAILED);
 
-		if (mesh_tx) {
-			if (sending)
-				mgmt_mesh_remove(mesh_tx);
-		}
+		if (mesh_tx)
+			mgmt_mesh_remove(mesh_tx);
 	} else {
 		hci_dev_set_flag(hdev, HCI_MESH_SENDING);
 
-- 
2.34.1


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

end of thread, other threads:[~2026-11-04  8:46 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: free the mesh tx if queueing the send fails Wentao Liang
2026-11-04  7:12 ` Krzysztof Kozlowski
2026-11-04  8:46 ` 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