_nx_icmp_interface_ping does not release request_ptr packet when failing with NX_NO_RESPONSE
When using nx_icmp_ping, I found that when I provided an IP address which was not on my network, the function would timeout and return NX_NO_RESPONSE as expected. However, I also noticed that my packet pool available count would reduce by one every time I did this.
I verified that the packet pool would not deplete when the ping response is received successfully.
Please also mention any information which could help others to understand the problem you're facing:
- What target device are you using? Custom Renesas Synergy S5D9 hardware
- Which version of Eclipse ThreadX? 6.4.0
- What toolchain and environment? arm-none-eabi-gcc 9.2.1.20191025
- What have you tried to diagnose or workaround this issue? Since nx_packet_release is a safe function to call for null pointers, I added a call to release the packet in the failure case:
nx_icmp_interface_ping.c:
` /* If wait option is requested, suspend the thread. */ if (wait_option) {
/* Release the protection on the ARP list. */
tx_mutex_put(&(ip_ptr -> nx_ip_protection));
/* Call actual thread suspension routine. */
_tx_thread_system_suspend(thread_ptr);
if (thread_ptr -> tx_thread_suspend_status == NX_SUCCESS)
{
/* Add debug information. */
NX_PACKET_DEBUG(__FILE__, __LINE__, *response_ptr);
line 379 } +++ else +++ { +++ /* Release the packet. */ +++ _nx_packet_release(request_ptr); +++ }
/* Return the status from the thread control block. */
return(thread_ptr -> tx_thread_suspend_status);
}
else
{
`
To Reproduce Call nxd_icmp_ping, providing any IP address which will not return a response.
Expected behavior Function returns NX_NO_RESPONSE, but does not leak the request packets created and used internally.
Impact None, workaround works for me.
Logs and console output None
Additional context None
We will look into this @agrutter. Thank you for raising the issue!