This is an automated email from the ASF dual-hosted git repository. yamamoto pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 102adaf arch: esp32: Fix a memory leak when discarding a large packet. 102adaf is described below commit 102adaf0268e3d9ab6ba14d5dfe7a65f1750ebe9 Author: Masayuki Ishikawa <masayuki.ishik...@gmail.com> AuthorDate: Tue Feb 16 15:13:30 2021 +0900 arch: esp32: Fix a memory leak when discarding a large packet. Summary: - Recently I noticed that ESP32-DevKitC-32D suddenly stops during receiving ping packets from PC after 10-20mins - Actually, sometimes memory leak happened when some device sent a big broadcast packet periodically on the network - This commit fixes this issue by calling esp_wifi_free_eb() in the case that the packet exceeds WLAN_BUF_SIZE. - Also, this commit applies the same logic in the case that the Wi-Fi interface is down Impact: - None Testing: - Tested with esp32-devkitc:wapi Suggested-by: YAMAMOTO Takashi <yamam...@midokura.com> Signed-off-by: Masayuki Ishikawa <masayuki.ishik...@jp.sony.com> --- arch/xtensa/src/esp32/esp32_wlan.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/xtensa/src/esp32/esp32_wlan.c b/arch/xtensa/src/esp32/esp32_wlan.c index fe2b906..6578843 100644 --- a/arch/xtensa/src/esp32/esp32_wlan.c +++ b/arch/xtensa/src/esp32/esp32_wlan.c @@ -483,28 +483,26 @@ static int wlan_rx_done(void *buffer, uint16_t len, void *eb) struct wlan_rxbuf *rxbuf; irqstate_t flags; FAR struct wlan_priv_s *priv = &g_wlan_priv; + int ret = 0; if (!priv->ifup) { - return 0; + goto out; } if (len > WLAN_BUF_SIZE) { nwarn("ERROR: Wlan receive %d larger than %d\n", len, WLAN_BUF_SIZE); - return -EINVAL; + ret = -EINVAL; + goto out; } rxbuf = wlan_alloc_buffer(priv); if (!rxbuf) { - if (eb) - { - esp_wifi_free_eb(eb); - } - - return -ENOBUFS; + ret = -ENOBUFS; + goto out; } memcpy(rxbuf->buffer, buffer, len); @@ -525,6 +523,14 @@ static int wlan_rx_done(void *buffer, uint16_t len, void *eb) } return 0; + +out: + if (eb) + { + esp_wifi_free_eb(eb); + } + + return ret; } /****************************************************************************