Leases based on MAC addresses

Chuck Anderson cra at WPI.EDU
Tue Feb 17 14:26:58 UTC 2009


On Tue, Feb 17, 2009 at 07:08:30AM -0700, Elliot Finley wrote:
> David W. Hankins wrote:
>> On Mon, Feb 16, 2009 at 01:04:37PM -0700, Elliot Finley wrote:
>>>   			tuid = (unsigned char *)dmalloc (lt -> uid_max, MDL);
>>>   			if (!tuid)
>>>   				log_fatal ("no memory for large uid.");
>>>   			memcpy (tuid, d1.data, lt -> uid_len);
>>> ! 			//EOFlt -> uid = tuid;
>>
>> That's a memory leak.
>
> After running with this patch for the last 16 hours on a relatively busy  
> server (lease file has about 42000 leases, it hands out about 2-3 leases  
>  per second), the memory used (as shown by 'top') hasn't changed at all.

For very large UIDs, the 2nd block of code (in the else clause) will 
allocate memory for tuid.  Since you commented out the last line 
there, tuid is not copied anywhere and so it is never freed 
anywhere-->memory leak.  If you are ignoring uid completely, you may 
as well never run any of that code-->comment out the entire 
if/then/else block.



More information about the dhcp-users mailing list