libkmod: move kmod_file_load_contents as applicable

When dealing with an elf, we don't know or care about loading the file.
The kmod_elf subsystem/API will deal with the required parts itself.

Which in this case, already calls kmod_file_load_contents() as
applicable.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
Emil Velikov 2024-02-12 17:23:08 +00:00 committed by Lucas De Marchi
parent 81e5c797d0
commit 8cc475f7da

View File

@ -903,10 +903,6 @@ static int do_init_module(struct kmod_module *mod, unsigned int flags,
off_t size;
int err;
err = kmod_file_load_contents(mod->file);
if (err)
return err;
if (flags & (KMOD_INSERT_FORCE_VERMAGIC | KMOD_INSERT_FORCE_MODVERSION)) {
elf = kmod_file_get_elf(mod->file);
if (elf == NULL) {
@ -928,6 +924,10 @@ static int do_init_module(struct kmod_module *mod, unsigned int flags,
mem = kmod_elf_get_memory(elf);
} else {
err = kmod_file_load_contents(mod->file);
if (err)
return err;
mem = kmod_file_get_contents(mod->file);
}
size = kmod_file_get_size(mod->file);