Commit 8a565c0a authored by Gaetan Perrot's avatar Gaetan Perrot Committed by Daniel DeGrasse
Browse files

modules: hostap: supp_events: Fix possible null deference



Move usage of ap_ctx pointers after null checks to prevent potential
crashes.

Signed-off-by: default avatarGaetan Perrot <gaetan.perrot@spacecubics.com>
parent cd855104
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -304,13 +304,15 @@ int supplicant_send_wifi_mgmt_ap_sta_event(void *ctx,
{
{
	struct sta_info *sta = data;
	struct sta_info *sta = data;
	struct wpa_supplicant *ap_ctx = ctx;
	struct wpa_supplicant *ap_ctx = ctx;
	char *ifname = ap_ctx->ifname;
	char *ifname;
	struct wifi_ap_sta_info sta_info = { 0 };
	struct wifi_ap_sta_info sta_info = { 0 };


	if (!ap_ctx || !sta) {
	if (!ap_ctx || !sta) {
		return -EINVAL;
		return -EINVAL;
	}
	}


	ifname = ap_ctx->ifname;

	memcpy(sta_info.mac, sta->addr, sizeof(sta_info.mac));
	memcpy(sta_info.mac, sta->addr, sizeof(sta_info.mac));


	if (event == NET_EVENT_WIFI_CMD_AP_STA_CONNECTED) {
	if (event == NET_EVENT_WIFI_CMD_AP_STA_CONNECTED) {