From 0e27218ef6f815b57236d7b306cf16f1a1c452b5 Mon Sep 17 00:00:00 2001 From: rdkdevpilot Date: Fri, 5 Dec 2025 14:30:33 -0500 Subject: [PATCH] wifi_8021x: fix null pointer dereference in process_eap_data The process_eap_data function was dereferencing data->data before checking if the pointers were NULL, which could lead to segmentation faults. This commit moves the null checks to the beginning of the function and returns early if null pointers are detected, preventing the dereference from occurring. Changes: - Add null check for data and data->data at function start - Return early with error logging if NULL - Remove redundant null checks before free() calls --- source/core/wifi_8021x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/core/wifi_8021x.c b/source/core/wifi_8021x.c index eb0fbfbf1..12c7692d1 100644 --- a/source/core/wifi_8021x.c +++ b/source/core/wifi_8021x.c @@ -53,6 +53,11 @@ void process_eap_data(wifi_8021x_data_t *data, wifi_8021x_t *module, bool new_ev gettimeofday(&tnow, NULL); + if (data == NULL || data->data == NULL) { + wifi_util_error_print(WIFI_MON, "%s:%d: NULL pointer encountered\n", __func__, __LINE__); + return; + } + eap = (wifi_eap_frame_t *)data->data; to_mac_str(data->mac, mac_str); @@ -67,10 +72,8 @@ void process_eap_data(wifi_8021x_data_t *data, wifi_8021x_t *module, bool new_ev wifi_util_dbg_print(WIFI_MON, "%s:%d: Removing from hash and deleting\n", __func__, __LINE__); hash_map_remove(module->bssid[data->vap].sta_map, mac_str); - if (data->data != NULL) - free(data->data); - if (data != NULL) - free(data); + free(data->data); + free(data); } return;