From e182d75ef7b4030a02e62bf483c33e58dbcce006 Mon Sep 17 00:00:00 2001 From: Joakim Andersson Date: Wed, 5 Jun 2019 10:56:54 +0200 Subject: [PATCH] Bluetooth: host: Fix gatt indicate when conn is NULL Fix gatt indicate when conn is NULL and called with characteristic declaration as the attribute argument. In this case the handle was not advanced to the characteristic value. This is inconsistent with the rest of the notify and indicate API Signed-off-by: Joakim Andersson --- subsys/bluetooth/host/gatt.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 5d9ef867b12..1bb1610f22e 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -1388,17 +1388,6 @@ static int gatt_indicate(struct bt_conn *conn, u16_t handle, } #endif - /* Check if attribute is a characteristic then adjust the handle */ - if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) { - struct bt_gatt_chrc *chrc = params->attr->user_data; - - if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) { - return -EINVAL; - } - - handle++; - } - buf = bt_att_create_pdu(conn, BT_ATT_OP_INDICATE, sizeof(*ind) + params->len); if (!buf) { @@ -1615,6 +1604,17 @@ int bt_gatt_indicate(struct bt_conn *conn, return -ENOENT; } + /* Check if attribute is a characteristic then adjust the handle */ + if (!bt_uuid_cmp(params->attr->uuid, BT_UUID_GATT_CHRC)) { + struct bt_gatt_chrc *chrc = params->attr->user_data; + + if (!(chrc->properties & BT_GATT_CHRC_INDICATE)) { + return -EINVAL; + } + + handle++; + } + if (conn) { return gatt_indicate(conn, handle, params); }