monitor: Fix ATT decoding issue
authorIulia Tanasescu <iulia.tanasescu@nxp.com>
Thu, 7 Sep 2023 15:12:28 +0000 (18:12 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:04 +0000 (19:04 +0530)
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

index d0d566e..70ac164 100755 (executable)
@@ -171,7 +171,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)
 {
@@ -191,7 +193,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;
@@ -235,6 +237,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;
                }
        }