Project

General

Profile

Feature #2735

Updated by Vadim Mutilin over 9 years ago

# At the end all allocated memory should be free.  
 # It’s not allowed to free the same memory twice.  
 # It’s not allowed to free not allocated memory. 

 *Description* 

 The dynamic allocation is widely used in Linux. The incorrect usage of heap may lead to memory leaks or even to failures, when the module tries to free not allocated memory. So, the correct usage of heap includes 
 *    Freeing all allocated memory to avoid a memory leak. 
 *    Freeing an allocated memory only once. 
 *    Freeing only allocated memory. 

 Memory allocation functions are _kmalloc_ and _kzalloc_, a free function is _kfree_. It is correct to free the null pointer. 

 *Links* 
 "Sample bugfix":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=c0cc35919317b579b23514c1385f246f348852ad Sample bugfixes "4a349aa":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=4a349aa, "a9e7fb5":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=a9e7fb5, "d47b389":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=d47b389, "c1c7415":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=c1c7415, "8a9f335":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=8a9f335, "723342c":https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=723342c 

 *Note* 
 This is a _generic:resource:leaks_ class of our classifier.

Back