Bluetooth: GATT: Fix potential bt_conn reference leak

There was a missing bt_conn_unref() when bt_conn_lookup_addr_le()
returns a connection that's not in BT_CONN_CONNECTED state.

Change-Id: I4c6271d5bf596ea4d9b899e99ce1c7b7c8693f5e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2016-09-12 21:37:39 +03:00
commit 3a3238d1b0

View file

@ -543,7 +543,12 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, void *user_data)
}
conn = bt_conn_lookup_addr_le(&ccc->cfg[i].peer);
if (!conn || conn->state != BT_CONN_CONNECTED) {
if (!conn) {
continue;
}
if (conn->state != BT_CONN_CONNECTED) {
bt_conn_unref(conn);
continue;
}