FREE(9r)FREE(9r)NAMEFREE - General: Deallocates (frees) the allocated kernel virtual memory
int type );
Specifies the memory pointer that points to the allocated memory to be
freed. You must have previously set this pointer in the call to MALLOC.
You also define the data type for this argument in the call to MALLOC.
Specifies the purpose for which the memory is being allocated. The
memory types are defined in the file <malloc.h>. Typically, kernel mod‐
ules use the constant M_DEVBUF to indicate that kernel module memory is
being allocated (or freed).
The FREE routine deallocates (frees) the allocated kernel virtual mem‐
ory, which you allocated in a previous call to MALLOC.
A memory corruption can occur if a kernel module continues to use the
memory after freeing it. The operating system provides a built-in mech‐
anism to debug such erroneous use of memory. You can enable this debug‐
ging feature at boot time by providing the following boot parameter:
kmem_debug=1. When you enable this debugging feature, the FREE routine
stores the following in the last word of freed memory: The program
counter (pc) of the module that last freed the memory The checksum of
the memory content
The MALLOC routine checks the checksum of the memory content before
reallocating this corrupted memory. If the checksum of the memory con‐
tent does not match the corrupted memory, MALLOC stores the debug
information and then causes the kernel to panic. The MALLOC routine
stores the address and size of the corrupted memory and the pc of the
routine that last freed it in a kmem_corrupt_data structure.
You should consider the following when using this debugging feature:
This debugging feature does not detect cases where the corruption
occurs after malloc reallocates the freed memory to some other module.
There is a small chance that the pc of the routine that freed the mem‐
ory (stored in the last word of freed memory) may itself become cor‐