Skip to content

Commit 9ddfed2

Browse files
andreas.larssonadbridge
authored andcommitted
Added missing checks for wifi_link_out when allocating packets
1 parent 2c1c845 commit 9ddfed2

File tree

1 file changed

+10
-3
lines changed
  • targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac

1 file changed

+10
-3
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,16 @@ static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf)
267267
(void)emac;
268268
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
269269
emac_stack_mem_t *new_buf = emac_stack_mem_alloc(emac, emac_stack_mem_chain_len(emac,buf),0);
270-
emac_stack_mem_copy(emac,new_buf,buf);
271-
cbMAIN_getEventQueue()->call(send_packet,emac,new_buf);
272-
cbMAIN_dispatchEventQueue();
270+
if (new_buf != NULL) {
271+
emac_stack_mem_copy(emac, new_buf, buf);
272+
int id = cbMAIN_getEventQueue()->call(send_packet, emac, new_buf);
273+
if (id != 0) {
274+
cbMAIN_dispatchEventQueue();
275+
}
276+
else {
277+
emac_stack_mem_free(emac, new_buf);
278+
}
279+
}
273280
return true;
274281
}
275282

0 commit comments

Comments
 (0)