esp_wifi: netif: set interface before registering Wi-Fi driver RX callback

If appropriate interface is not set then RX callback can potentially dereference
null pointer from `s_wifi_netifs` table. This in-fact resulted in `LoadProhibited` exception
in HTTP server example test case.

Order here for setting interface and then registering callback was correct but
it was modified in 0e71a325de309400b68f018da7df52f1890c57ba causing this regression.
This commit is contained in:
Mahavir Jain 2022-07-06 09:03:08 +05:30
parent 8417079218
commit f45dbd1f97
No known key found for this signature in database
GPG Key ID: 99324EF4A00734E0

View File

@ -133,10 +133,13 @@ esp_err_t esp_wifi_register_if_rxcb(wifi_netif_driver_t ifx, esp_netif_receive_t
return ESP_ERR_NOT_SUPPORTED;
}
/* Interface must be set before registering Wi-Fi RX callback */
set_wifi_netif(wifi_interface, esp_netif_get_netif_impl(arg));
if ((ret = esp_wifi_internal_reg_rxcb(wifi_interface, rxcb)) != ESP_OK) {
ESP_LOGE(TAG, "esp_wifi_internal_reg_rxcb for if=%d failed with %d", wifi_interface, ret);
return ESP_ERR_INVALID_STATE;
}
set_wifi_netif(wifi_interface, esp_netif_get_netif_impl(arg));
return ESP_OK;
}