[En-Nut-Discussion] Memory leak in DHCP process

Jörg Wiegelmann joerg.wiegelmann at gmx.de
Tue Oct 8 17:01:52 CEST 2019


Dear folks,

I'm hunting a very seldom shutdown of a ethernut application. After a
very long journey, I think I found a problem in the Nut OS DHCP logic. 

After the DHCP Lease time the Ethernut client is rebinding to the DHCP
Server. In this process the application is calling the NutDhcpIfConfig
function.
This function looses memory in this way:

NutDhcpIfConfig->NutDhcpIfConfig2->NutNetIfSetup->NutIpRouteAdd->malloc
without free!!!!

It's around 48 bytes with every call. To avoid this I changed the
NutOs-DHCP-Client in this way (marked with >).

With this modification we don't loosing memory anymore.

Comments to this are welcome! I hope anyone is listening to this group.
NutOs is a great system, but where is anybody ;-) ? On the Linux planet
or on freeRtos or... ?

Best regards Jörg

------------------------------------------------

 /*
         * We are done somehow. Either a fatal error occured or we
         * reached the specified timeout time or our lease has been
         * release or something else configured our interface.
         * Release all resources and wait for a new API call to
         * wake us up.
         */
        else if (dhcpState == DHCPST_IDLE) {
            ReleaseDynCfg(dhcpConfig);
            dhcpConfig = 0;
            retries = 0;
            NutEventBroadcast(&dhcpDone);
            /* #wi releas Memory for routes */
  >          if(dhcpDev!=0)
  >                          {
  >                         NutIpRouteDelAll(dhcpDev); // Alle Routen
löschen, damit Speicher wieder frei gegeben wird. #wi Fehlerbehebung.....
  >                          }
---------------------------------------------



More information about the En-Nut-Discussion mailing list