monitor/att: Fix crash when accessing packet_conn
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 3 Dec 2022 00:04:43 +0000 (16:04 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 10:11:34 +0000 (15:41 +0530)
This fixes the following crash:

:monitor/att.c:2697:11: runtime error: member access within null
pointer of type 'struct att_conn_data'

monitor/att.c

index 68ad790..db68187 100644 (file)
@@ -2575,7 +2575,12 @@ static void att_conn_data_free(void *data)
 
 static struct att_conn_data *att_get_conn_data(struct packet_conn_data *conn)
 {
-       struct att_conn_data *data = conn->data;
+       struct att_conn_data *data;
+
+       if (!conn)
+               return NULL;
+
+       data = conn->data;
 
        if (data)
                return data;
@@ -2609,6 +2614,8 @@ static void att_read_type_req(const struct l2cap_frame *frame)
 
        conn = packet_get_conn_data(frame->handle);
        data = att_get_conn_data(conn);
+       if (!data)
+               return;
 
        if (!data->reads)
                data->reads = queue_new();