Page 1 of 1

crash in dhcp_recv function in dhcp.c

Posted: Thu Nov 09, 2017 5:00 pm
by jesper
I have an Ethernet and Wifi board out on some sites.
At one place it would crash everytime Ethernet got at IP, on others it was ok.
This started to pop up with one of the lastest ESP-IDF versions, presumably because of changes to the ethernet and tcpip_adapter code.
I assign a static address to Ethernet and turn off DHCP.

Nailed this down to an issue in dhcp recv:

At the start of the function:

Code: Select all

  /* Caught DHCP message from netif that does not have DHCP enabled? -> not interested */
  if((dhcp == NULL) || (dhcp->pcb_allocated == 0)) {
    goto free_pbuf_and_return;
  }
And at the end:

Code: Select all

free_pbuf_and_return:
  dhcp->msg_in = NULL;
  pbuf_free(p);
The

Code: Select all

dhcp->msg_in = NULL
would cause a StoreProhibited error as dhcp was NULL.

The fix is simple:

Code: Select all

free_pbuf_and_return:
  if (dhcp)
      dhcp->msg_in = NULL;
  pbuf_free(p);

/Jesper

Re: crash in dhcp_recv function in dhcp.c

Posted: Fri Nov 10, 2017 2:25 am
by WiFive
Can you do pull request on GitHub?

Re: crash in dhcp_recv function in dhcp.c

Posted: Sat Nov 11, 2017 5:28 am
by jesper
If I knew how to do that, I would have, LOL
Guess it's something I'll have to learn anyway, I'll see if I can find some information on how to do it.