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

2025-06-17 Thread Daniel Gomez
>> 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? > > I noticed this too, specifically because move_module() is inco

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

2025-06-17 Thread Petr Pavlu
On 6/17/25 11:47 AM, Daniel Gomez wrote: >> 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; >> >>

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

2025-06-17 Thread Daniel Gomez
> 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) { >

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

2025-06-16 Thread Petr Pavlu
On 6/14/25 11:28 PM, Daniel Gomez wrote: >> This seems to be off by one. For instance, if the loop reaches the last >> valid type in mod_mem_type, MOD_INIT_RODATA, and successfully allocates >> its memory, the variable t gets set to MOD_INIT_RODATA. Subsequently, if >> an error occurs later in move

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

2025-06-14 Thread Daniel Gomez
> This seems to be off by one. For instance, if the loop reaches the last > valid type in mod_mem_type, MOD_INIT_RODATA, and successfully allocates > its memory, the variable t gets set to MOD_INIT_RODATA. Subsequently, if > an error occurs later in move_module() and control is transferred to > out

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

2025-06-12 Thread Petr Pavlu
On 6/10/25 8:51 PM, Daniel Gomez wrote: > On 07/06/2025 18.16, Petr Pavlu wrote: >> The function move_module() uses the variable t to track how many memory >> types it has allocated and consequently how many should be freed if an >> error occurs. >> >> The variable is initially set to 0 and is upda

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

2025-06-10 Thread Daniel Gomez
On 07/06/2025 18.16, Petr Pavlu wrote: > The function move_module() uses the variable t to track how many memory > types it has allocated and consequently how many should be freed if an > error occurs. > > The variable is initially set to 0 and is updated when a call to > module_memory_alloc() fai

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

2025-06-09 Thread Sami Tolvanen
On Sun, Jun 08, 2025 at 09:25:34AM +0200, Petr Pavlu wrote: > On 6/7/25 6:16 PM, Petr Pavlu wrote: > > The function move_module() uses the variable t to track how many memory > > types it has allocated and consequently how many should be freed if an > > error occurs. > > > > The variable is initia

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

2025-06-08 Thread Petr Pavlu
On 6/7/25 6:16 PM, Petr Pavlu wrote: > The function move_module() uses the variable t to track how many memory > types it has allocated and consequently how many should be freed if an > error occurs. > > The variable is initially set to 0 and is updated when a call to > module_memory_alloc() fails