Commit ca3881f6 authored by Petr Pavlu's avatar Petr Pavlu Committed by Daniel Gomez
Browse files

module: Fix memory deallocation on error path in move_module()



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. However, move_module() can fail for other
reasons as well, in which case t remains set to 0 and no memory is freed.

Fix the problem by initializing t to MOD_MEM_NUM_TYPES. Additionally, make
the deallocation loop more robust by not relying on the mod_mem_type_t enum
having a signed integer as its underlying type.

Fixes: c7ee8aeb ("module: add stop-grap sanity check on module memcpy()")
Signed-off-by: default avatarPetr Pavlu <petr.pavlu@suse.com>
Reviewed-by: default avatarSami Tolvanen <samitolvanen@google.com>
Reviewed-by: default avatarDaniel Gomez <da.gomez@samsung.com>
Link: https://lore.kernel.org/r/20250618122730.51324-2-petr.pavlu@suse.com


Signed-off-by: default avatarDaniel Gomez <da.gomez@samsung.com>
Message-ID: <20250618122730.51324-2-petr.pavlu@suse.com>
parent d7b8f8e2
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment