diff --git a/include/wifi_base.h b/include/wifi_base.h index def0ede47..281c60bd0 100644 --- a/include/wifi_base.h +++ b/include/wifi_base.h @@ -474,7 +474,6 @@ typedef struct { client_stats_enable_t flag; instant_msmt_t imsmt; active_msmt_t amsmt; - associated_devs_t devs; csi_mon_t csi_mon; wifi_mon_stats_config_t mon_stats_config; frame_data_t msg; diff --git a/source/apps/linkquality/wifi_linkquality.c b/source/apps/linkquality/wifi_linkquality.c index 462c7df72..d88b6c606 100644 --- a/source/apps/linkquality/wifi_linkquality.c +++ b/source/apps/linkquality/wifi_linkquality.c @@ -67,6 +67,7 @@ void publish_qmgr_subdoc(const report_batch_t* report) if (webconfig_encode(&ctrl->webconfig, data, subdoc_type) != webconfig_error_none) { wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d Error in encoding link report\n", __func__, __LINE__); + webconfig_data_free(data); free(data); return; } @@ -80,17 +81,22 @@ void publish_qmgr_subdoc(const report_batch_t* report) wifi_app = get_app_by_inst(&ctrl->apps_mgr, wifi_app_inst_link_quality); if (wifi_app == NULL) { wifi_util_error_print(WIFI_APPS, "%s:%d NULL Pointer \n", __func__, __LINE__); + webconfig_data_free(data); + free(data); return; } status = get_bus_descriptor()->bus_event_publish_fn(&wifi_app->ctrl->handle, WIFI_QUALITY_LINKREPORT, &rdata); if (status != bus_error_success) { wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: bus: bus_event_publish_fn Event failed %d\n", __func__, __LINE__, status); + webconfig_data_free(data); free(data); return ; } - if(data) + if (data) { + webconfig_data_free(data); free(data); + } return; } diff --git a/source/core/wifi_multidoc_webconfig.c b/source/core/wifi_multidoc_webconfig.c index 498a7f127..dd105b7e4 100644 --- a/source/core/wifi_multidoc_webconfig.c +++ b/source/core/wifi_multidoc_webconfig.c @@ -1330,18 +1330,14 @@ static int update_vap_info_managed_guest(void *data, void *amenities_blob, wifi_ static int update_vap_info_managed_xfinity(void *data, wifi_vap_info_t *vap_info, pErr execRetVal) { int status = RETURN_OK; - cJSON *root = NULL; cJSON *param = NULL; bool connected_building_enabled = false; - char *blob = cJSON_Print((cJSON *)data); - - root = cJSON_Parse(blob); - if (root == NULL) { - wifi_util_error_print(WIFI_CTRL, "%s:Managed xfinity json parse failure\n", __func__); + if (data == NULL) { return RETURN_ERR; } - param = cJSON_GetObjectItem(root, "connected_building_enabled"); + + param = cJSON_GetObjectItem((cJSON *)data, "connected_building_enabled"); if (param) { if (cJSON_IsBool(param)) { @@ -1349,7 +1345,6 @@ static int update_vap_info_managed_xfinity(void *data, wifi_vap_info_t *vap_info wifi_util_dbg_print(WIFI_CTRL, " \"connected_building_enabled\": %s\n", (connected_building_enabled) ? "true" : "false"); } else { wifi_util_dbg_print(WIFI_CTRL, "%s: \"connected_building_enabled\" is not boolean\n", __func__); - cJSON_Delete(root); return RETURN_ERR; } } else { @@ -1357,7 +1352,6 @@ static int update_vap_info_managed_xfinity(void *data, wifi_vap_info_t *vap_info } vap_info->u.bss_info.connected_building_enabled = connected_building_enabled; wifi_util_info_print(WIFI_CTRL, " LINE %d \"connected_building_enabled\": %s and vap_name=%s\n", __LINE__,(vap_info->u.bss_info.connected_building_enabled) ? "true" : "false",vap_info->vap_name); - cJSON_Delete(root); return status; } @@ -1743,6 +1737,7 @@ pErr wifi_vap_cfg_subdoc_handler(void *data) cJSON_Delete(root); goto finished; } + cJSON_Delete(root); free(execRetVal); execRetVal = xfinity_exec_common_handler(vap_blob, webconfig_subdoc_type_xfinity); @@ -2003,6 +1998,7 @@ pErr webconf_process_managed_subdoc(void* data) wifi_util_error_print(WIFI_CTRL, "%s: json parse failure\n", __func__); return execRetVal; } + cJSON *managed_wifi_enabled = cJSON_GetObjectItem(root, "ManagedWifiEnabled"); if (managed_wifi_enabled == NULL) { msgpack_zone_destroy(&msg_z); @@ -2036,6 +2032,7 @@ pErr webconf_process_managed_subdoc(void* data) strncpy(execRetVal->ErrorMsg, "Failed to detach WifiVapConfig", sizeof(execRetVal->ErrorMsg)-1); free(blob_buf); free(msg); + cJSON_Delete(amenities_blob); cJSON_Delete(root); wifi_util_error_print(WIFI_CTRL, "%s: Failed to detach WifiVapConfig\n", __func__); return execRetVal; @@ -2045,11 +2042,14 @@ pErr webconf_process_managed_subdoc(void* data) msgpack_zone_destroy(&msg_z); execRetVal->ErrorCode = VALIDATION_FALIED; free(blob_buf); - free(msg); + free(msg); + cJSON_Delete(amenities_blob); + cJSON_Delete(vap_blob); cJSON_Delete(root); - wifi_util_error_print(WIFI_CTRL, "%s: Failed to detach xfinity_blob\n", __func__); + wifi_util_error_print(WIFI_CTRL, "%s: connected_subdoc_handler failed for lnf vaps\n", __func__); return execRetVal; } + cJSON *xfinity_blob = cJSON_DetachItemFromObject(root, "xfinityWifiVapConfig"); if(xfinity_blob == NULL) { msgpack_zone_destroy(&msg_z); @@ -2057,8 +2057,10 @@ pErr webconf_process_managed_subdoc(void* data) strncpy(execRetVal->ErrorMsg, "Failed to detach xfinity_blob", sizeof(execRetVal->ErrorMsg)-1); free(blob_buf); free(msg); + cJSON_Delete(amenities_blob); + cJSON_Delete(vap_blob); cJSON_Delete(root); - wifi_util_error_print(WIFI_CTRL, "%s: Failed to detach xfinity_blob\n", __func__); + wifi_util_error_print(WIFI_CTRL, "%s: Failed to detach xfinityWifiVapConfig\n", __func__); return execRetVal; } @@ -2068,19 +2070,28 @@ pErr webconf_process_managed_subdoc(void* data) execRetVal->ErrorCode = VALIDATION_FALIED; free(blob_buf); free(msg); + cJSON_Delete(amenities_blob); + cJSON_Delete(vap_blob); + cJSON_Delete(xfinity_blob); cJSON_Delete(root); - wifi_util_error_print(WIFI_CTRL, "%s: Failed to update connectedbuilding AVPs in Xfinity vaps \n", __func__); + wifi_util_error_print(WIFI_CTRL, "%s: Failed to update connectedbuilding AVPs in Xfinity vaps\n", __func__); return execRetVal; } + if (connected_wifi_enabled) { wifi_util_info_print(WIFI_CTRL,"lnf_psk vaps are repurposed to managed_guest\n"); } else { wifi_util_info_print(WIFI_CTRL,"managed_guest vaps are reverted back to lnf_psk\n"); } - wifi_util_info_print(WIFI_CTRL,"Managed guest blob is applied successfuly \n"); - cJSON_Delete(root); // don't need this anymore + cJSON_Delete(amenities_blob); + cJSON_Delete(vap_blob); + cJSON_Delete(xfinity_blob); + cJSON_Delete(root); + free(blob_buf); + free(msg); + msgpack_zone_destroy(&msg_z); execRetVal->ErrorCode = BLOB_EXEC_SUCCESS; return execRetVal; diff --git a/source/db/wifi_db_apis.c b/source/db/wifi_db_apis.c index 5b9fb692e..2becf8ace 100644 --- a/source/db/wifi_db_apis.c +++ b/source/db/wifi_db_apis.c @@ -3291,7 +3291,6 @@ int wifidb_update_ignite_config(ignite_config_t *ignite_cfg) pcfg = onewifi_ovsdb_table_select_where(g_wifidb->wifidb_sock_path, &table_Wifi_Ignite_Config, where, &count); - if (where) { json_decref(where); where = NULL; } if (pcfg && count > 0) { memcpy(&cfg, pcfg, sizeof(cfg)); update = true; @@ -3331,7 +3330,6 @@ int wifidb_update_ignite_config(ignite_config_t *ignite_cfg) ret = onewifi_ovsdb_table_update_where(g_wifidb->wifidb_sock_path, &table_Wifi_Ignite_Config, where, &cfg); - if (where) { json_decref(where); where = NULL; } if (ret <= 0) { wifi_util_error_print(WIFI_CTRL, "%s:%d Update failed\n", diff --git a/source/webconfig/wifi_encoder.c b/source/webconfig/wifi_encoder.c index c87f6ea29..e48c89ecf 100644 --- a/source/webconfig/wifi_encoder.c +++ b/source/webconfig/wifi_encoder.c @@ -2749,17 +2749,10 @@ webconfig_error_t encode_radio_channel_radio_params(wifi_provider_response_t *ch radio_chan_data_t *chan_data = chan_stats->stat_pointer; - radio_stats_obj = cJSON_CreateObject(); - if (radio_stats_obj == NULL) { - wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d json object creation failed\n", __func__, __LINE__); - return webconfig_error_encode; - } - for (unsigned int count = 0; count < chan_stats->stat_array_size; count++) { radio_stats_obj = cJSON_CreateObject(); if (radio_stats_obj == NULL) { wifi_util_error_print(WIFI_WEBCONFIG, "%s:%d: json create object failed\n", __func__, __LINE__); - cJSON_Delete(radio_stats_obj); return webconfig_error_encode; } cJSON_AddItemToArray(radio_stats, radio_stats_obj);