diff mbox series

[BlueZ,2/3] monitor: Fix ATT decoding issue

Message ID 20230907151229.7306-3-iulia.tanasescu@nxp.com (mailing list archive)
State Accepted
Commit 42681a7c15ab21783001cf3921e99a594693ae55
Headers show
Series shared/bass: Add Set Broadcast_Code opcode handler | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Iulia Tanasescu Sept. 7, 2023, 3:12 p.m. UTC
This fixes the way conn handles are marked as unused in the
conn_list array, so that valid conn entries are not overwritten
by new ones.

---
 monitor/packet.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/monitor/packet.c b/monitor/packet.c
index 279f5408d..f88a11539 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -172,7 +172,9 @@  static uint16_t get_format(uint32_t cookie)
 
 #define MAX_CONN 16
 
-static struct packet_conn_data conn_list[MAX_CONN];
+static struct packet_conn_data conn_list[MAX_CONN] = {
+	 [0 ... MAX_CONN - 1].handle = 0xffff
+};
 
 static struct packet_conn_data *lookup_parent(uint16_t handle)
 {
@@ -192,7 +194,7 @@  static void assign_handle(uint16_t index, uint16_t handle, uint8_t type,
 	int i;
 
 	for (i = 0; i < MAX_CONN; i++) {
-		if (conn_list[i].handle == 0x0000) {
+		if (conn_list[i].handle == 0xffff) {
 			hci_devba(index, (bdaddr_t *)conn_list[i].src);
 
 			conn_list[i].index = index;
@@ -236,6 +238,7 @@  static void release_handle(uint16_t handle)
 			queue_destroy(conn->tx_q, free);
 			queue_destroy(conn->chan_q, free);
 			memset(conn, 0, sizeof(*conn));
+			conn->handle = 0xffff;
 			break;
 		}
 	}