mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-05-21 09:05:59 +08:00
fix(tcpip_adapter): Fix recv pbuf memory leak
This commit is contained in:
@ -403,6 +403,7 @@ void ethernetif_input(struct netif* netif, struct pbuf* p)
|
|||||||
|
|
||||||
if (netif == NULL) {
|
if (netif == NULL) {
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: netif is NULL\n"));
|
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: netif is NULL\n"));
|
||||||
|
pbuf_free(p);
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,12 +229,12 @@ static int tcpip_adapter_recv_cb(void *index, void *buffer, uint16_t len, void *
|
|||||||
|
|
||||||
p = os_malloc(sizeof(struct tcpip_adapter_pbuf));
|
p = os_malloc(sizeof(struct tcpip_adapter_pbuf));
|
||||||
if (!p)
|
if (!p)
|
||||||
return -ENOMEM;
|
goto no_mem;
|
||||||
|
|
||||||
// PBUF_RAW means payload = (char *)aio->pbuf + offset(=0)
|
// PBUF_RAW means payload = (char *)aio->pbuf + offset(=0)
|
||||||
pbuf = pbuf_alloced_custom(PBUF_RAW, len, PBUF_REF, &p->pbuf, buffer, len);
|
pbuf = pbuf_alloced_custom(PBUF_RAW, len, PBUF_REF, &p->pbuf, buffer, len);
|
||||||
if (!pbuf)
|
if (!pbuf)
|
||||||
return -ENOMEM;
|
goto pbuf_err;
|
||||||
|
|
||||||
p->pbuf.custom_free_function = tcpip_adapter_free_pbuf;
|
p->pbuf.custom_free_function = tcpip_adapter_free_pbuf;
|
||||||
p->eb = (void *)eb;
|
p->eb = (void *)eb;
|
||||||
@ -243,6 +243,11 @@ static int tcpip_adapter_recv_cb(void *index, void *buffer, uint16_t len, void *
|
|||||||
ethernetif_input(netif, pbuf);
|
ethernetif_input(netif, pbuf);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
pbuf_err:
|
||||||
|
os_free(p);
|
||||||
|
no_mem:
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user