monitor/att: Fix not removing read from queue
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 20 May 2022 23:17:11 +0000 (16:17 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
The code was using queue_find instead of queue_remove_if so follow up
read wouldn't match the attribute properly.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
monitor/att.c

index 9323796..61eaa9c 100644 (file)
@@ -541,7 +541,7 @@ static void att_read_req(const struct l2cap_frame *frame)
                return;
 
        handler = get_handler(attr);
-       if (!handler)
+       if (!handler || !handler->read)
                return;
 
        conn = packet_get_conn_data(frame->handle);
@@ -580,11 +580,13 @@ static void att_read_rsp(const struct l2cap_frame *frame)
 
        data = conn->data;
 
-       read = queue_find(data->reads, match_read_frame, frame);
+       read = queue_remove_if(data->reads, match_read_frame, (void *)frame);
        if (!read)
                return;
 
        read->func(frame);
+
+       free(read);
 }
 
 static void att_read_blob_req(const struct l2cap_frame *frame)