From 32dfe73b096aec4be31f6624e17250fa3cf1ef80 Mon Sep 17 00:00:00 2001 From: "andreas.larsson" Date: Mon, 31 Oct 2016 14:52:27 +0100 Subject: [PATCH] Added missing checks for wifi_link_out when allocating packets --- .../sdk/wifi_emac/wifi_emac_api.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp b/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp index 1d42b02474..d1148ade4e 100644 --- a/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp +++ b/targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp @@ -267,9 +267,16 @@ static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf) (void)emac; // Break call chain to avoid the driver affecting stack usage for the IP stack thread too much emac_stack_mem_t *new_buf = emac_stack_mem_alloc(emac, emac_stack_mem_chain_len(emac,buf),0); - emac_stack_mem_copy(emac,new_buf,buf); - cbMAIN_getEventQueue()->call(send_packet,emac,new_buf); - cbMAIN_dispatchEventQueue(); + if (new_buf != NULL) { + emac_stack_mem_copy(emac, new_buf, buf); + int id = cbMAIN_getEventQueue()->call(send_packet, emac, new_buf); + if (id != 0) { + cbMAIN_dispatchEventQueue(); + } + else { + emac_stack_mem_free(emac, new_buf); + } + } return true; }