I'm writing a device driver that, among other things, allocates a block of memory with kmalloc
. This memory is freed when the user program closes the file. In one of my experiments, the user program crashed without closing the file.
Would anything have freed this memory?
In another experiment, I moved the kfree()
from the close()
function to the module_exit()
function. When I ran the user program twice consecutively, I called kmalloc
again with the same pointer as before, without freeing it first. Thus, I lost a pointer to that memory, and cannot free it.
Is this memory lost to the system until I reboot, or will it be freed when I unload the driver?