From: Emil Velikov Date: Wed, 7 May 2025 16:50:03 +0000 (+0100) Subject: testsuite/init-module: error out init_module() on kmod failure X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=426154c62a14c4d9c65706e9d9732c2d29eab2bc;p=thirdparty%2Fkmod.git testsuite/init-module: error out init_module() on kmod failure Currently our wrapper init_module() will happily return success whenever libkmod fails. While such failures are unlikely, our wrapper should also fail. In part so it doesn't mask a potentially deeper problem and in part because the kmod API used, will set errno... Something a normal syscall wouldn't do AFAICT. v2: - remove the respective comment Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/346 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/init_module.c b/testsuite/init_module.c index 6d39fdba..a8fa58bb 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -236,15 +236,14 @@ long init_module(void *mem, unsigned long len, const char *args) elf = kmod_elf_new(mem, len); if (elf == NULL) - return 0; + return -1; err = kmod_elf_get_section(elf, ".gnu.linkonce.this_module", &off, &bufsize); buf = (const char *)kmod_elf_get_memory(elf) + off; kmod_elf_unref(elf); - /* We couldn't parse the ELF file. Just exit as if it was successful */ if (err < 0) - return 0; + return -1; /* We need to open both 32 and 64 bits module - hack! */ class = elf_identify(mem);