From eb4ec4beda1e2d7a1e1314e7d48d609cfad19e56 Mon Sep 17 00:00:00 2001 From: wangjialiang Date: Mon, 5 Sep 2022 20:27:57 +0800 Subject: [PATCH] ble_mesh: stack: added the judgment that the parameter is NULL but the parameter len is not zero to avoid btc_transfer_context failed --- components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c | 2 +- components/bt/esp_ble_mesh/btc/btc_ble_mesh_config_model.c | 4 ++-- components/bt/esp_ble_mesh/btc/btc_ble_mesh_generic_model.c | 4 ++-- components/bt/esp_ble_mesh/btc/btc_ble_mesh_health_model.c | 4 ++-- components/bt/esp_ble_mesh/btc/btc_ble_mesh_lighting_model.c | 4 ++-- components/bt/esp_ble_mesh/btc/btc_ble_mesh_prov.c | 4 ++-- components/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 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c index 6c66a29de66..8fb22a10676 100644 --- a/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c +++ b/components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c @@ -90,7 +90,7 @@ static void btc_ble_mesh_ble_callback(esp_ble_mesh_ble_cb_param_t *cb_params, ui msg.pid = BTC_PID_BLE_MESH_BLE_COEX; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_ble_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_ble_cb_param_t), btc_ble_mesh_ble_copy_req_data); } 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 22dccaa7b2e..a9c7ca0d177 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 @@ -306,7 +306,7 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param msg.pid = BTC_PID_CONFIG_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_client_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_cfg_client_cb_param_t), btc_ble_mesh_config_client_copy_req_data); } @@ -710,7 +710,7 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param msg.pid = BTC_PID_CONFIG_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL); + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL); } void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model, 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 c73b43155e4..222eb39266a 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 @@ -376,7 +376,7 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_ msg.pid = BTC_PID_GENERIC_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_generic_client_copy_req_data); } @@ -693,7 +693,7 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_ msg.pid = BTC_PID_GENERIC_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_generic_server_cb_param_t), btc_ble_mesh_generic_server_copy_req_data); } 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 2cc8dcf7788..996a353cac6 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 @@ -239,7 +239,7 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa msg.pid = BTC_PID_HEALTH_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data); } @@ -550,7 +550,7 @@ static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_pa msg.pid = BTC_PID_HEALTH_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data); } 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 8ece595a99b..254065f3a80 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 @@ -220,7 +220,7 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p msg.pid = BTC_PID_LIGHTING_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_lighting_client_copy_req_data); } @@ -505,7 +505,7 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c msg.pid = BTC_PID_LIGHTING_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_lighting_server_cb_param_t), btc_ble_mesh_lighting_server_copy_req_data); } 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 0361595b5f6..0eab5620bec 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 @@ -376,7 +376,7 @@ static bt_status_t btc_ble_mesh_model_callback(esp_ble_mesh_model_cb_param_t *pa msg.pid = BTC_PID_MODEL; msg.act = act; - ret = btc_transfer_context(&msg, param, sizeof(esp_ble_mesh_model_cb_param_t), + ret = btc_transfer_context(&msg, param, param == NULL ? 0 : sizeof(esp_ble_mesh_model_cb_param_t), btc_ble_mesh_model_copy_req_data); if (ret != BT_STATUS_SUCCESS) { BT_ERR("btc_transfer_context failed"); @@ -536,7 +536,7 @@ static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *para msg.pid = BTC_PID_PROV; msg.act = act; - ret = btc_transfer_context(&msg, param, sizeof(esp_ble_mesh_prov_cb_param_t), NULL); + ret = btc_transfer_context(&msg, param, param == NULL ? 0 : sizeof(esp_ble_mesh_prov_cb_param_t), NULL); if (ret != BT_STATUS_SUCCESS) { BT_ERR("btc_transfer_context failed"); } 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 9e6c1ae3b7f..d3ef66c4de4 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 @@ -458,7 +458,7 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa msg.pid = BTC_PID_SENSOR_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_sensor_client_copy_req_data); } @@ -825,7 +825,7 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa msg.pid = BTC_PID_SENSOR_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_sensor_server_cb_param_t), btc_ble_mesh_sensor_server_copy_req_data); } 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 66ad4eaaecb..90e4d251756 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 @@ -222,7 +222,7 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie msg.pid = BTC_PID_TIME_SCENE_CLIENT; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t), + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_time_scene_client_copy_req_data); } @@ -409,7 +409,7 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv msg.pid = BTC_PID_TIME_SCENE_SERVER; msg.act = act; - btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL); + btc_transfer_context(&msg, cb_params, cb_params == NULL ? 0 : sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL); } void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,