Message ID | 20221216210611.2990552-1-luiz.dentz@gmail.com |
---|---|
State | New |
Headers | show |
Series | [v2] shared/gatt-client: Fix not marking service as active | expand |
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=705220 ---Test result--- Test Summary: CheckPatch PASS 0.40 seconds GitLint PASS 0.26 seconds BuildEll PASS 26.35 seconds BluezMake PASS 766.01 seconds MakeCheck PASS 11.24 seconds MakeDistcheck PASS 147.97 seconds CheckValgrind PASS 239.23 seconds bluezmakeextell PASS 93.67 seconds IncrementalBuild PASS 615.21 seconds ScanBuild WARNING 949.04 seconds Details ############################## Test: ScanBuild - WARNING Desc: Run Scan Build Output: src/shared/gatt-client.c:387:21: warning: Use of memory after it is freed gatt_db_unregister(op->client->db, op->db_id); ^~~~~~~~~~ src/shared/gatt-client.c:616:2: warning: Use of memory after it is freed discovery_op_complete(op, false, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:919:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1028:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1220:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1285:2: warning: Use of memory after it is freed discovery_op_complete(op, success, att_ecode); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1556:6: warning: Use of memory after it is freed if (read_db_hash(op)) { ^~~~~~~~~~~~~~~~ src/shared/gatt-client.c:1561:2: warning: Use of memory after it is freed discover_all(op); ^~~~~~~~~~~~~~~~ src/shared/gatt-client.c:2063:6: warning: Use of memory after it is freed if (read_db_hash(op)) { ^~~~~~~~~~~~~~~~ src/shared/gatt-client.c:2071:8: warning: Use of memory after it is freed discovery_op_ref(op), ^~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:3154:2: warning: Use of memory after it is freed complete_write_long_op(req, success, 0, false); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-client.c:3176:2: warning: Use of memory after it is freed request_unref(req); ^~~~~~~~~~~~~~~~~~ 12 warnings generated. --- Regards, Linux Bluetooth
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index cf0d2e2b749d..83283110b636 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -576,12 +576,28 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, gatt_db_attribute_get_handle(attr), handle); goto failed; } + + if (!gatt_db_attribute_get_service_data(attr, NULL, &end, + NULL, NULL)) { + DBG(client, "Unable to get service data at 0x%04x", + handle); + goto failed; + } + + /* Skip if there are no attributes */ + if (handle == end) + gatt_db_service_set_active(attr, true); } next: range = queue_pop_head(op->discov_ranges); - if (!range) + if (!range) { + /* If there are no range to discover mark current service as + * active. + */ + gatt_db_service_set_active(op->cur_svc, true); goto failed; + } client->discovery_req = bt_gatt_discover_characteristics(client->att, range->start, @@ -725,6 +741,9 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) goto failed; } + /* Done with the current service */ + gatt_db_service_set_active(op->cur_svc, true); + done: free(chrc_data); return true;
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> If there are no characteristics to discover, or for some reason bt_gatt_discover_descriptors is skiped, or the last attribute is actually a included service the service should be marked as active as there will be no more attributes to be discovered. Fixes: https://github.com/bluez/bluez/issues/438 --- src/shared/gatt-client.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)