Bluetooth: gatt: Fix missing return and assignment to invalid type

This patch adds missing return call. Destroy was called early,
on read params. This could result in memory violation.

Another thing that has been fixed is assignment of bt_gatt_read
return value which can be negative to uint8_t type.

Change-Id: I1ddfea03038538efd70ad8ac68bd8df308a4ee3c
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-11-16 12:14:58 +01:00 committed by Anas Nashif
commit d6c1a09e18

View file

@ -1136,11 +1136,12 @@ static void att_read_rsp(struct bt_conn *conn, uint8_t err, const void *pdu,
params->offset += length; params->offset += length;
/* Continue reading the attribute */ /* Continue reading the attribute */
err = bt_gatt_read(conn, params); if (bt_gatt_read(conn, params) < 0) {
if (err) { params->func(conn, BT_ATT_ERR_UNLIKELY, NULL, 0);
params->func(conn, err, NULL, 0); goto done;
} }
return;
done: done:
if (params->destroy) { if (params->destroy) {
params->destroy(params); params->destroy(params);