crash in dhcp_recv function in dhcp.c

jesper
Posts: 25
Joined: Thu Nov 09, 2017 4:38 pm

crash in dhcp_recv function in dhcp.c

Postby jesper » Thu Nov 09, 2017 5:00 pm

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
MagicMicros Co., Ltd. - Rayong, Thailand
Electronics design, PCB layout & programming.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: crash in dhcp_recv function in dhcp.c

Postby WiFive » Fri Nov 10, 2017 2:25 am

Can you do pull request on GitHub?

jesper
Posts: 25
Joined: Thu Nov 09, 2017 4:38 pm

Re: crash in dhcp_recv function in dhcp.c

Postby jesper » Sat Nov 11, 2017 5:28 am

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.
MagicMicros Co., Ltd. - Rayong, Thailand
Electronics design, PCB layout & programming.

Who is online

Users browsing this forum: No registered users and 51 guests