From 38e9784ab7621790cebe8bee8cff469b2d64001f Mon Sep 17 00:00:00 2001 From: Abhay Agarwal Date: Tue, 18 Aug 2020 10:09:51 +0530 Subject: [PATCH] Mesh: Fix crash in node reset This patch fix crash due to g_free of node information in delete node setup. This patch also removes the lauch timer during deinit of mesh. Change-Id: I29e3406b57fd06042fcdfb88c43ef047422ddbb6 Signed-off-by: Abhay Agarwal --- bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c | 1 - bt-service/services/mesh/bt-service-mesh-main.c | 5 +++++ bt-service/services/mesh/bt-service-mesh-network.c | 8 +++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c b/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c index b7ab8ab..a548554 100644 --- a/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c +++ b/bt-oal/bluez_hal/src/bt-hal-mesh-dbus-handler.c @@ -2315,7 +2315,6 @@ static void __bt_hal_mesh_delete_node_setup(struct l_dbus_message *msg, l_dbus_message_set_arguments(msg, "qy", node_info->unicast, node_info->num_elements); INFO("Mesh: Delete Remote Node Setup params passed"); - g_free(node_info); } static void __bt_hal_mesh_delete_node_reply( diff --git a/bt-service/services/mesh/bt-service-mesh-main.c b/bt-service/services/mesh/bt-service-mesh-main.c index a5313c5..56dc71b2 100644 --- a/bt-service/services/mesh/bt-service-mesh-main.c +++ b/bt-service/services/mesh/bt-service-mesh-main.c @@ -834,6 +834,11 @@ int _bt_mesh_deinit(void) oal_status_t status = OAL_STATUS_SUCCESS; int ret = UNIT_CONTROL_OK; + if (launch_timer > 0) { + g_source_remove(launch_timer); + launch_timer = 0; + } + /* Terminate bluetooth-meshd */ ret = actd_stop_unit(UNIT_CONTROL_BUS_TYPE_SYSTEM, MESH_SYSTEMD_SERVICE_NAME, 5000); diff --git a/bt-service/services/mesh/bt-service-mesh-network.c b/bt-service/services/mesh/bt-service-mesh-network.c index 24fa6fc..43db8fc 100644 --- a/bt-service/services/mesh/bt-service-mesh-network.c +++ b/bt-service/services/mesh/bt-service-mesh-network.c @@ -453,7 +453,8 @@ int _bt_mesh_network_scan_cancel(const char *app_cred, } _bt_mesh_util_convert_string_to_hex(network->uuid, strlen(network->uuid), net_uuid.uuid, 16); - /* Register Mesh Node */ + + /* Cancel unprovisioned device scan */ ret = mesh_network_scan_cancel(&net_uuid); if (ret != OAL_STATUS_SUCCESS) { BT_ERR("ret: %d", ret); @@ -473,7 +474,7 @@ int _bt_mesh_network_set_provisioner_caps(const char *app_cred, _bt_mesh_util_convert_string_to_hex(network->uuid, strlen(network->uuid), net_uuid.uuid, 16); - /* Register Mesh Node */ + /* Set provisioning capabilities */ ret = mesh_network_set_provisioning_capabilities(&net_uuid, (oal_mesh_capabilities_t*) caps); if (ret != OAL_STATUS_SUCCESS) { @@ -1261,9 +1262,6 @@ int _bt_mesh_network_add_remote_node(uint8_t net_uuid[], _bt_mesh_conf_insert_node_object(cdb_cfg, /* Dev UUID */ dev_uuid, count, unicast, MESH_PRIMARY_NET_IDX); - /* Mark Provisioning state to done */ - _bt_mesh_set_provisioning_state(true); - return BLUETOOTH_ERROR_NONE; } -- 2.7.4