Skip to content

Commit

Permalink
Merge pull request RIOT-OS#12947 from gschorcht/cpu/esp32/fix_send_bu…
Browse files Browse the repository at this point in the history
…ffer

cpu/esp32: esp_wifi send buffer should not be on stack
  • Loading branch information
benpicco authored Dec 14, 2019
2 parents 7dbf5c6 + e6db925 commit 2ed87d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpu/esp32/esp-wifi/esp_wifi_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -360,15 +363,14 @@ 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) {
if (tx_len + iol->iol_len > ETHERNET_MAX_LEN) {
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;
}
}
Expand Down

0 comments on commit 2ed87d5

Please sign in to comment.