mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
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 <yamamoto@midokura.com> Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
committed by
YAMAMOTO Takashi
parent
6e08c4dca3
commit
102adaf026
@@ -483,28 +483,26 @@ static int wlan_rx_done(void *buffer, uint16_t len, void *eb)
|
|||||||
struct wlan_rxbuf *rxbuf;
|
struct wlan_rxbuf *rxbuf;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
FAR struct wlan_priv_s *priv = &g_wlan_priv;
|
FAR struct wlan_priv_s *priv = &g_wlan_priv;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (!priv->ifup)
|
if (!priv->ifup)
|
||||||
{
|
{
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > WLAN_BUF_SIZE)
|
if (len > WLAN_BUF_SIZE)
|
||||||
{
|
{
|
||||||
nwarn("ERROR: Wlan receive %d larger than %d\n",
|
nwarn("ERROR: Wlan receive %d larger than %d\n",
|
||||||
len, WLAN_BUF_SIZE);
|
len, WLAN_BUF_SIZE);
|
||||||
return -EINVAL;
|
ret = -EINVAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rxbuf = wlan_alloc_buffer(priv);
|
rxbuf = wlan_alloc_buffer(priv);
|
||||||
if (!rxbuf)
|
if (!rxbuf)
|
||||||
{
|
{
|
||||||
if (eb)
|
ret = -ENOBUFS;
|
||||||
{
|
goto out;
|
||||||
esp_wifi_free_eb(eb);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -ENOBUFS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(rxbuf->buffer, buffer, len);
|
memcpy(rxbuf->buffer, buffer, len);
|
||||||
@@ -525,6 +523,14 @@ static int wlan_rx_done(void *buffer, uint16_t len, void *eb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (eb)
|
||||||
|
{
|
||||||
|
esp_wifi_free_eb(eb);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user