From 1e20ed4849e2dc69dd670fbc54c129244d4c37fe Mon Sep 17 00:00:00 2001 From: lly Date: Mon, 2 Sep 2019 13:08:05 +0800 Subject: [PATCH] ble_mesh: fix failed to set device role caused mem leak --- .../bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c | 4 ++-- .../bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c | 4 ++-- .../bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c | 4 ++-- .../bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c | 4 ++-- components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c | 8 ++++---- .../bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c | 4 ++-- .../bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c index bfab0a9e1c..7d4d865b3f 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c @@ -612,7 +612,7 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) role_param.role = cb.params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } btc_ble_mesh_config_client_get_state(arg->cfg_client_get_state.params, arg->cfg_client_get_state.get_state, @@ -628,7 +628,7 @@ void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg) role_param.role = cb.params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } btc_ble_mesh_config_client_set_state(arg->cfg_client_set_state.params, arg->cfg_client_set_state.set_state, diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c index e155a49fad..f13b86bb6f 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c @@ -458,7 +458,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; @@ -484,7 +484,7 @@ void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c index a38b52dab2..5e1e01e958 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c @@ -410,7 +410,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) role_param.role = cb.params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params, arg->health_client_get_state.get_state, &cb); @@ -426,7 +426,7 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg) role_param.role = cb.params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params, arg->health_client_set_state.set_state, &cb); diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c index fdac1b6fe7..fdb5d2e49a 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c @@ -302,7 +302,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; @@ -328,7 +328,7 @@ void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c index 31639aff43..b0619d7090 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c @@ -1454,7 +1454,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) common.role = arg->model_publish.device_role; if (bt_mesh_set_client_model_role(&common)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } } err = bt_mesh_model_publish((struct bt_mesh_model *)arg->model_publish.model); @@ -1466,7 +1466,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + 8); if (!buf) { LOG_ERROR("%s, Failed to allocate memory", __func__); - return; + break; } net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length); arg->model_send.ctx->srv_send = true; @@ -1484,7 +1484,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) struct net_buf_simple *buf = bt_mesh_alloc_buf(arg->model_send.length + 8); if (!buf) { LOG_ERROR("%s, Failed to allocate memory", __func__); - return; + break; } net_buf_simple_add_mem(buf, arg->model_send.data, arg->model_send.length); arg->model_send.ctx->srv_send = false; @@ -1492,7 +1492,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg) common.role = arg->model_send.device_role; if (bt_mesh_set_client_model_role(&common)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } err = bt_mesh_client_send_msg((struct bt_mesh_model *)arg->model_send.model, arg->model_send.opcode, diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c index 0eff3e9f4a..f3766f1d46 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c @@ -547,7 +547,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; @@ -573,7 +573,7 @@ void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c index 4691d3f423..c87b67237a 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c @@ -304,7 +304,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model; @@ -330,7 +330,7 @@ void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg) role_param.role = params->msg_role; if (bt_mesh_set_client_model_role(&role_param)) { LOG_ERROR("%s, Failed to set model role", __func__); - return; + break; } common.opcode = params->opcode; common.model = (struct bt_mesh_model *)params->model;