From 203f871420d8e9449bd476c870e899a1c2757f9d Mon Sep 17 00:00:00 2001 From: lly Date: Wed, 25 Mar 2020 00:10:59 +0800 Subject: [PATCH] ble_mesh: Fix provisioning buffer initialization [Zephyr] When PB-GATT support has been enabled the provisioning code "borrows" the buffer from the proxy code. However, the way that initialization was happening the proxy buffers were initialized only after provisioning initialization, resulting in a corrupted buffer with buf->data pointing to NULL. Reorder the initialization calls so that proxy is done first and provisioning only after it. --- components/bt/esp_ble_mesh/mesh_core/main.c | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/bt/esp_ble_mesh/mesh_core/main.c b/components/bt/esp_ble_mesh/mesh_core/main.c index f293a68d3..ff2a92f45 100644 --- a/components/bt/esp_ble_mesh/mesh_core/main.c +++ b/components/bt/esp_ble_mesh/mesh_core/main.c @@ -334,6 +334,19 @@ int bt_mesh_init(const struct bt_mesh_prov *prov, bt_mesh_gatt_init(); } + if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) { + if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || + IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { + bt_mesh_proxy_init(); + } + if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && + IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || + IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { + bt_mesh_proxy_prov_client_init(); + } + } + if (IS_ENABLED(CONFIG_BLE_MESH_PROV)) { if (IS_ENABLED(CONFIG_BLE_MESH_NODE)) { err = bt_mesh_prov_init(prov); @@ -363,19 +376,6 @@ int bt_mesh_init(const struct bt_mesh_prov *prov, bt_mesh_adv_init(); - if (IS_ENABLED(CONFIG_BLE_MESH_PROXY)) { - if ((IS_ENABLED(CONFIG_BLE_MESH_NODE) && - IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || - IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) { - bt_mesh_proxy_init(); - } - if ((IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && - IS_ENABLED(CONFIG_BLE_MESH_PB_GATT)) || - IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) { - bt_mesh_proxy_prov_client_init(); - } - } - if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER)) { bt_mesh_provisioner_init(); }