shared/gatt-client: Fix possible crash
Luiz Augusto von Dentz
maintainerPATCH 1/1 shared/gatt-client: Fix possible crash
From: Luiz Augusto von Dentz <[email protected]>
Similar to issue found with unit test it is necessary to protect bt_gatt_client instance before calling the callback otherwise it may destroy it causing a crash.
--- src/shared/gatt-client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
src/shared/gatt-client.c +4 -1
@@ -2456,14 +2456,17 @@ static void complete_write_long_op(struct request *req, bool success,if (req->att_id)return ; -request_unref (req); success = false; +bt_gatt_client_ref (op->client); +if (op->callback) op->callback (success, reliable_error, att_ecode, op->user_data);start_next_long_write (op->client); + +bt_gatt_client_unref (op->client); } static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t length,
Signature · 1 line
2.1.0
Hi,
Quoted 33 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Similar to issue found with unit test it is necessary to protect
bt_gatt_clientinstance before calling the callback otherwise it may destroy it causing a crash.--- src/shared/gatt-client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)src/shared/gatt-client.c +4
-2@@ -2456,14 +2456,17 @@ static void complete_write_long_op(struct request *req, bool success,if (req->att_id)return ; -request_unref (req); success = false; +bt_gatt_client_ref (op->client); +if (op->callback) op->callback (success, reliable_error, att_ecode, op->user_data);start_next_long_write (op->client); + +bt_gatt_client_unref (op->client); } static void prepare_write_cb(uint8_t opcode, const void *pdu, uint16_t length, --
Quoted 1 line
2.1.0
Applied.
Signature · 1 line
Luiz Augusto von Dentz