From e6db92567ef4f9f625571c203f4d05c2811dfb73 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sat, 14 Dec 2019 10:20:56 +0100 Subject: [PATCH] cpu/esp32: esp_wifi send buffer should not be on stack The buffer[EHTHERNET_MAX_LEN] used in _esp_wifi_send to convert the iolist of the given packet to a plain buffer for the WiFi interface should not be on the stack to prevent the sending thread's stack from overflowing. --- cpu/esp32/esp-wifi/esp_wifi_netdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpu/esp32/esp-wifi/esp_wifi_netdev.c b/cpu/esp32/esp-wifi/esp_wifi_netdev.c index 17cd287887e5..9fc9f7194561 100644 --- a/cpu/esp32/esp-wifi/esp_wifi_netdev.c +++ b/cpu/esp32/esp-wifi/esp_wifi_netdev.c @@ -347,6 +347,9 @@ static int _esp_wifi_init(netdev_t *netdev) return 0; } +/* transmit buffer should bot be on stack */ +static uint8_t _tx_buf[ETHERNET_MAX_LEN]; + static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist) { ESP_WIFI_DEBUG("%p %p", netdev, iolist); @@ -360,7 +363,6 @@ static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist) } uint16_t tx_len = 0; /**< number of bytes in transmit buffer */ - uint8_t tx_buf[ETHERNET_MAX_LEN]; /**< transmit buffer */ /* load packet data into TX buffer */ for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) { @@ -368,7 +370,7 @@ static int _esp_wifi_send(netdev_t *netdev, const iolist_t *iolist) return -EOVERFLOW; } if (iol->iol_len) { - memcpy (tx_buf + tx_len, iol->iol_base, iol->iol_len); + memcpy (_tx_buf + tx_len, iol->iol_base, iol->iol_len); tx_len += iol->iol_len; } }