diff --git a/components/lwip/port/esp8266/netif/ethernetif.c b/components/lwip/port/esp8266/netif/ethernetif.c index e4e375ff..ce63956f 100644 --- a/components/lwip/port/esp8266/netif/ethernetif.c +++ b/components/lwip/port/esp8266/netif/ethernetif.c @@ -403,6 +403,7 @@ void ethernetif_input(struct netif* netif, struct pbuf* p) if (netif == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: netif is NULL\n")); + pbuf_free(p); goto _exit; } diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 86d4b271..69aaa3f0 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -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)); if (!p) - return -ENOMEM; + goto no_mem; // PBUF_RAW means payload = (char *)aio->pbuf + offset(=0) pbuf = pbuf_alloced_custom(PBUF_RAW, len, PBUF_REF, &p->pbuf, buffer, len); if (!pbuf) - return -ENOMEM; + goto pbuf_err; p->pbuf.custom_free_function = tcpip_adapter_free_pbuf; 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); return 0; + +pbuf_err: + os_free(p); +no_mem: + return -ENOMEM; } /*