From 8e1fd164a7960962235f3757d4e49df7c0229ea0 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 20 May 2022 16:36:57 -0700 Subject: [PATCH] monitor/att: Fix not matching read frame direction There could be read frames pending on both direction so this ensures the direction is matched properly. --- monitor/att.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/monitor/att.c b/monitor/att.c index 51d83e649..d06a1b223 100644 --- a/monitor/att.c +++ b/monitor/att.c @@ -404,7 +404,8 @@ static void att_read_type_rsp(const struct l2cap_frame *frame) struct att_read { struct gatt_db_attribute *attr; - uint16_t cid; + bool in; + uint16_t chan; void (*func)(const struct l2cap_frame *frame); }; @@ -553,7 +554,8 @@ static void att_read_req(const struct l2cap_frame *frame) read = new0(struct att_read, 1); read->attr = attr; - read->cid = frame->cid; + read->in = frame->in; + read->chan = frame->chan; read->func = handler->read; queue_push_tail(data->reads, read); @@ -564,7 +566,13 @@ static bool match_read_frame(const void *data, const void *match_data) const struct att_read *read = data; const struct l2cap_frame *frame = match_data; - return read->cid == frame->cid; + /* Read frame and response frame shall be in the opposite direction to + * match. + */ + if (read->in == frame->in) + return false; + + return read->chan == frame->chan; } static void att_read_rsp(const struct l2cap_frame *frame) -- 2.47.3