Bluetooth: Check CCC before allocating buffer

Fixes memory leak when buffer is allocated before CCC check, the best
fix is to move CCC check forward.

Change-Id: Ib0492f629a339b576cf811adce47b2f6ab101c33
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2015-06-01 12:58:49 +03:00 committed by Anas Nashif
commit 382488bbd0

View file

@ -303,6 +303,11 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
struct bt_buf *buf;
struct bt_att_notify *nfy;
/* TODO: Handle indications */
if (ccc->value != BT_GATT_CCC_NOTIFY) {
continue;
}
conn = bt_conn_lookup_addr_le(&ccc->cfg[i].peer);
if (!conn) {
continue;
@ -315,11 +320,6 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
return BT_GATT_ITER_STOP;
}
/* TODO: Handle indications */
if (ccc->value != BT_GATT_CCC_NOTIFY) {
continue;
}
BT_DBG("conn %p handle %u\n", conn, data->handle);
nfy = bt_buf_add(buf, sizeof(*nfy));