diff options
author | Emil Velikov <emil.l.velikov@gmail.com> | 2024-02-12 17:23:08 +0000 |
---|---|---|
committer | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2024-04-30 12:33:52 -0500 |
commit | 8cc475f7da3bb6e8e211ebcba141d38527980eb8 (patch) | |
tree | cc2db6137a0b1304bd31eef4a57b4e1ffb7930dd | |
parent | 81e5c797d0620ce719dee84a89878b8eca762340 (diff) | |
download | kmod-8cc475f7da3bb6e8e211ebcba141d38527980eb8.tar.gz |
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>
-rw-r--r-- | libkmod/libkmod-module.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 1e43482..d309948 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -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); |