Skip to content

Commit 7ea02d9

Browse files
committed
Add error handling for getting null tx buffer
1 parent 2406197 commit 7ea02d9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

features/netsocket/emac-drivers/TARGET_NUVOTON_EMAC/numaker_emac.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,17 @@ bool NUMAKER_EMAC::link_out(emac_mem_buf_t *buf)
222222
{
223223
bool result;
224224
emac_mem_buf_t *q;
225-
uint8_t *buffer = numaker_eth_get_tx_buf();
225+
uint8_t *buffer = NULL;
226226
uint32_t framelength = 0;
227227
uint32_t bufferoffset = 0;
228228
uint32_t byteslefttocopy = 0;
229229
uint32_t payloadoffset = 0;
230230

231231
/* Get exclusive access */
232232
TXLockMutex.lock();
233+
buffer = numaker_eth_get_tx_buf();
233234
NU_DEBUGF(("%s ... buffer=0x%x\r\n",__FUNCTION__, buffer));
235+
if( buffer == NULL ) goto error;
234236
/* copy frame from buf to driver buffers */
235237
for (q = buf; q != NULL; q = memory_manager->get_next(q)) {
236238

0 commit comments

Comments
 (0)