mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
fix(ble-mesh): don't use dangling pointer in nimble gatt service
Signed-off-by: luoxu <luoxu@espressif.com> Merges https://github.com/espressif/esp-idf/pull/14140
This commit is contained in:
parent
6d79a72d62
commit
74d8feabca
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA
|
* SPDX-FileCopyrightText: 2017 Nordic Semiconductor ASA
|
||||||
* SPDX-FileCopyrightText: 2015-2016 Intel Corporation
|
* SPDX-FileCopyrightText: 2015-2016 Intel Corporation
|
||||||
* SPDX-FileContributor: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -1312,18 +1312,18 @@ int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
|
|
||||||
if (!svc) {
|
if (!svc) {
|
||||||
BT_ERR("%s, Invalid parameter", __func__);
|
BT_ERR("%s, Invalid parameter", __func__);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
const ble_uuid_t *uuid;
|
|
||||||
if (BLE_MESH_UUID_16(svc->attrs[0].user_data)->val == BT_UUID_MESH_PROXY_VAL) {
|
if (BLE_MESH_UUID_16(svc->attrs[0].user_data)->val == BT_UUID_MESH_PROXY_VAL) {
|
||||||
uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL);
|
rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL), &handle);
|
||||||
} else {
|
} else {
|
||||||
uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL);
|
rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL), &handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gatts_find_svc(uuid, &handle);
|
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
ble_gatts_svc_set_visibility(handle, 0);
|
ble_gatts_svc_set_visibility(handle, 0);
|
||||||
|
|
||||||
@ -1337,14 +1337,13 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
uint16_t handle;
|
uint16_t handle;
|
||||||
const ble_uuid_t *uuid;
|
|
||||||
if (BLE_MESH_UUID_16(svc->attrs[0].user_data)->val == BT_UUID_MESH_PROXY_VAL) {
|
if (BLE_MESH_UUID_16(svc->attrs[0].user_data)->val == BT_UUID_MESH_PROXY_VAL) {
|
||||||
uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL);
|
rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROXY_VAL), &handle);
|
||||||
} else {
|
} else {
|
||||||
uuid = BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL);
|
rc = ble_gatts_find_svc(BLE_UUID16_DECLARE(BT_UUID_MESH_PROV_VAL), &handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = ble_gatts_find_svc(uuid, &handle);
|
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
ble_gatts_svc_set_visibility(handle, 1);
|
ble_gatts_svc_set_visibility(handle, 1);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user