Re: [PATCH 1/2] module: Fix memory deallocation on error path in move_module()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Do you mean the following, or something else:
> 
> static int move_module(struct module *mod, struct load_info *info)
> {
> 	int i;
> 	enum mod_mem_type t = MOD_MEM_NUM_TYPES;
> 	int ret;
> 	bool codetag_section_found = false;
> 
> 	for_each_mod_mem_type(type) {
> 		if (!mod->mem[type].size) {
> 			mod->mem[type].base = NULL;
> 			continue;
> 		}
> 
> 		ret = module_memory_alloc(mod, type);
> 		if (ret) {
> 			t = type;
> 			goto out_err;
> 		}
> 	}
> 
> 	[...]
> }
> 

Yes, that's it. From your patch, moving MOD_MEM_NUM_TYPE assigment to the
initialization and use the while() loop suggested later on.

One thing though, we are "releasing" the memory even if we have skipped the
allocation in the first place. So, I think it would make sense to release only
for the types we have actually allocated. What do you think?




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux