Diff between 348f12a2d3cdca7590a3ce26bc61032e86ee5d55 and dd257e98db01aceeae48211f7d28840de30e138e

Changed Files

File Additions Deletions Status
src/shared/att.c +5 -0 modified

Full Patch

diff --git a/src/shared/att.c b/src/shared/att.c
index a5bf244..4be0652 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -722,6 +722,8 @@ static bool can_read_data(struct io *io, void *user_data)
 	pdu = att->buf;
 	opcode = pdu[0];
 
+	bt_att_ref(att);
+
 	/* Act on the received PDU based on the opcode type */
 	switch (get_op_type(opcode)) {
 	case ATT_OP_TYPE_RSP:
@@ -745,6 +747,7 @@ static bool can_read_data(struct io *io, void *user_data)
 					"Received request while another is "
 					"pending: 0x%02x", opcode);
 			io_shutdown(att->io);
+			bt_att_unref(att);
 
 			return false;
 		}
@@ -766,6 +769,8 @@ static bool can_read_data(struct io *io, void *user_data)
 		break;
 	}
 
+	bt_att_unref(att);
+
 	return true;
 }