mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/esp32: fixes serious memory leak in esp_wifi
The buffer given by the WiFi driver as parameter eb has to be freed explicitly. Otherwise the esp_wifi_netdev stops working after some seconds.
This commit is contained in:
parent
3ef35e1b78
commit
8a1da21b1a
@ -74,12 +74,22 @@ esp_err_t _esp_wifi_rx_cb(void *buffer, uint16_t len, void *eb)
|
||||
{
|
||||
DEBUG("%s: buf=%p len=%d eb=%p\n", __func__, buffer, len, eb);
|
||||
|
||||
CHECK_PARAM_RET (buffer != NULL, -EINVAL);
|
||||
CHECK_PARAM_RET (len <= ETHERNET_DATA_LEN, -EINVAL);
|
||||
if ((buffer == NULL) || (len >= ETHERNET_DATA_LEN)) {
|
||||
if (eb != NULL) {
|
||||
esp_wifi_internal_free_rx_buffer(eb);
|
||||
}
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mutex_lock(&_esp_wifi_dev.dev_lock);
|
||||
|
||||
/* copy the buffer and free WiFi driver buffer */
|
||||
memcpy(_esp_wifi_dev.rx_buf, buffer, len);
|
||||
if (eb) {
|
||||
esp_wifi_internal_free_rx_buffer(eb);
|
||||
}
|
||||
|
||||
/* trigger netdev event to read the data */
|
||||
_esp_wifi_dev.rx_len = len;
|
||||
_esp_wifi_dev.event = SYSTEM_EVENT_WIFI_RX_DONE;
|
||||
_esp_wifi_dev.netdev.event_callback(&_esp_wifi_dev.netdev, NETDEV_EVENT_ISR);
|
||||
|
Loading…
Reference in New Issue
Block a user