Skip to content

Commit cbfda0e

Browse files
author
Rami Elkhatib
committed
MPS2 CM3DS ethernet fix heap bug
The function SMSC9220_EMAC::low_level_input should create a heap for the packet equal to the size of the message (most of which are couple hundred bytes). The current code uses maximum frame size (1522 bytes) for each packet. This will cause the heap to quickly fill up. In fact, the default memory size (lwip.mem-size) used for this heap is 1600 bytes. This means that once you have one other packet allocated (extremely common), the heap allocation will always fails. Also, it is recommend to increase the default lwip.mem-size because that amount is very small especially if you send or receive a few large packets in the network. This is NOT done in current commit.
1 parent 14aa25b commit cbfda0e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

connectivity/drivers/emac/TARGET_ARM_SSG/COMPONENT_SMSC9220/smsc9220_emac.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ emac_mem_buf_t *SMSC9220_EMAC::low_level_input()
8989
message_length -= CRC_LENGTH_BYTES;
9090
}
9191
92-
p = _memory_manager->alloc_heap(SMSC9220_ETH_MAX_FRAME_SIZE,
92+
p = _memory_manager->alloc_heap(message_length,
9393
SMSC9220_BUFF_ALIGNMENT);
9494
9595
if (p != NULL) {

0 commit comments

Comments
 (0)