diff --git a/src/interfaces/csp_if_can_pbuf.c b/src/interfaces/csp_if_can_pbuf.c index faca94e1e..24c3360b8 100644 --- a/src/interfaces/csp_if_can_pbuf.c +++ b/src/interfaces/csp_if_can_pbuf.c @@ -36,7 +36,7 @@ void csp_can_pbuf_free(csp_can_interface_data_t * ifdata, csp_packet_t * buffer, csp_buffer_free_isr(packet); } } - + return; } prev = packet; @@ -73,14 +73,16 @@ void csp_can_pbuf_cleanup(csp_can_interface_data_t * ifdata, int * task_woken) { while (packet) { + csp_packet_t * next = packet->next; + /* Perform cleanup in used pbufs */ if (now - packet->last_used > PBUF_TIMEOUT_MS) { /* Erase from list prev->next = next */ if (prev) { - prev->next = packet->next; + prev->next = next; } else { - ifdata->pbufs = packet->next; + ifdata->pbufs = next; } if (task_woken == NULL) { @@ -89,10 +91,13 @@ void csp_can_pbuf_cleanup(csp_can_interface_data_t * ifdata, int * task_woken) { csp_buffer_free_isr(packet); } + packet = next; + continue; + } prev = packet; - packet = packet->next; + packet = next; } } diff --git a/src/interfaces/csp_if_eth_pbuf.c b/src/interfaces/csp_if_eth_pbuf.c index 3d7473645..b212ab08c 100644 --- a/src/interfaces/csp_if_eth_pbuf.c +++ b/src/interfaces/csp_if_eth_pbuf.c @@ -33,6 +33,7 @@ void csp_eth_pbuf_free(csp_eth_interface_data_t * ifdata, csp_packet_t * buffer, csp_buffer_free_isr(packet); } } + return; } prev = packet; @@ -68,14 +69,16 @@ void csp_eth_pbuf_cleanup(csp_eth_interface_data_t * ifdata, uint32_t now, int * while (packet) { + csp_packet_t * next = packet->next; + /* Perform cleanup in used pbufs */ if ((now - packet->last_used) > PBUF_TIMEOUT_MS) { /* Erase from list prev->next = next */ if (prev) { - prev->next = packet->next; + prev->next = next; } else { - ifdata->pbufs = packet->next; + ifdata->pbufs = next; } if (task_woken == NULL) { @@ -84,10 +87,13 @@ void csp_eth_pbuf_cleanup(csp_eth_interface_data_t * ifdata, uint32_t now, int * csp_buffer_free_isr(packet); } + packet = next; + continue; + } prev = packet; - packet = packet->next; + packet = next; } }