Project

General

Profile

Feature #4636

Updated by Vadim Mutilin almost 11 years ago

h2. Releasing resources of gendisk interface 

 h2. DESCRIPTION 

 The resources of gendisk interface should be released correctly. Otherwise it may lead to memory leaks and other errors caused by accessing nonexistent elements of gendisk. 
 For functions `alloc_disk`, `add_disk` it is required to use corresponding `put_disk`, `del_disk`. 

 h2. EXAMPLE 

 **Correct usage example:** 

 <pre> 
 struct gendisk* gd; 
 int init_module() 
 { 
 ... 
 gd=alloc_disk(32 /*the number of minor devices*/); 
 //further initialization of gendisk 
 gd->first_minor=0; 
 ... 
 } 

 void module_exit() 
 { 
 ... 
 //finishing work of gendisk and releasing resources 
 del_gendisk(gd); //switch off object interface 
 put_disk(gd); //free memory 
 } 
 </pre>

Back