From a2a45ed317a816a62f39cdeccfec45572668a769 Mon Sep 17 00:00:00 2001 From: Rajeev Katta Date: Fri, 5 Dec 2025 15:57:35 -0500 Subject: [PATCH] wifi_ctrl_webconfig: fix null pointer dereference in webconfig_stats_config_apply The webconfig_stats_config_apply function was dereferencing the data parameter before checking if it was NULL, which could lead to segmentation faults. This commit adds a null check at the beginning of the function and returns RETURN_ERR if the pointer is NULL. Changes: - Add null check for data parameter at function start - Return RETURN_ERR with error logging if NULL - Remove redundant null check in cleanup section --- source/core/wifi_ctrl_webconfig.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/core/wifi_ctrl_webconfig.c b/source/core/wifi_ctrl_webconfig.c index 573b1c406..79754712f 100644 --- a/source/core/wifi_ctrl_webconfig.c +++ b/source/core/wifi_ctrl_webconfig.c @@ -996,6 +996,11 @@ int webconfig_stats_config_apply(wifi_ctrl_t *ctrl, webconfig_subdoc_decoded_dat wifi_util_dbg_print(WIFI_CTRL,"%s %d \n", __func__, __LINE__); + if (data == NULL) { + wifi_util_error_print(WIFI_CTRL,"%s:%d data is NULL\n", __func__, __LINE__); + return RETURN_ERR; + } + mgr_cfg_map = mgr->stats_config_map; dec_cfg_map = data->stats_config_map; @@ -1056,7 +1061,7 @@ int webconfig_stats_config_apply(wifi_ctrl_t *ctrl, webconfig_subdoc_decoded_dat } free_data: - if ((data != NULL) && (dec_cfg_map != NULL)) { + if (dec_cfg_map != NULL) { wifi_util_dbg_print(WIFI_CTRL,"%s %d Freeing Decoded Data \n", __func__, __LINE__); dec_stats_config = hash_map_get_first(dec_cfg_map); while (dec_stats_config != NULL) {