>> 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 inconsistent > in this regard with free_mod_mem(). The latter function contains: > > if (mod_mem->size) > module_memory_free(mod, type); > > However, my preference is actually to update free_mod_mem() and remove > the check. The function module_memory_free() should be a no-op if > mod->base is NULL, similarly to how calling free(NULL) is a no-op. > Sound good to me. Perhaps a different patch type for cleanup/refactor. The fix here would be back-ported to stable branches. So these are 2 different things.