I am using KSDK 1.3 with MQX on a MK64F120 built with the IAR embedded workbench 220.127.116.1165. I have the HTTP and FTP servers running and I am using CGI and server side includes.
Occasionally I found the debugger stopped at the Hard Fault interrupt. Following the call stack back I found the source of the problem to be in ENET_free (although it may stem further back) where packet->PRIVATE is NULL but the code tries to read the deviceNumber from it. As this likely gets a bad number it then calls enet_critical_begin with the bad number which it uses as an array index and will sometimes cause the hard fault.
My fix is:
param = (enet_dev_if_t *)packet->PRIVATE;
//Adrian Rockall - packet->PRIVATE has somtimes come in as a NULL so try using a safe deviceNumber. Maybe we should just return
if (NULL == param)
count = 0;
count = param->deviceNumber;
But I'm not convinced this is the correct way to handle it. I presume deviceNumber refers to the ENET controller which should be OK on my board as I only have the one device. Should the function just return in this instance?
Does it point to a bug prior to reaching this point where packet->PRIVATE is not being filled in correctly?