Bluetooth: GATT: Fix possible bt_conn leak

If other peers were present but not in CONNECTED state temporary
connection reference was leaked.

Change-Id: Icc32bfe1a86f92a9d8472991476ebfd26c889d84
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2016-02-16 14:31:15 +01:00 committed by Gerrit Code Review
commit c80cf24e03

View file

@ -561,9 +561,13 @@ static uint8_t disconnected_cb(const struct bt_gatt_attr *attr, void *user_data)
/* Skip if there is another peer connected */
tmp = bt_conn_lookup_addr_le(&ccc->cfg[i].peer);
if (tmp && tmp->state == BT_CONN_CONNECTED) {
if (tmp) {
if (tmp->state == BT_CONN_CONNECTED) {
bt_conn_unref(tmp);
return BT_GATT_ITER_CONTINUE;
}
bt_conn_unref(tmp);
return BT_GATT_ITER_CONTINUE;
}
}
}