]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite/init-module: error out init_module() on kmod failure
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 7 May 2025 16:50:03 +0000 (17:50 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 20 May 2025 02:51:43 +0000 (21:51 -0500)
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 <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/346
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/init_module.c

index 6d39fdbaa43f15a94b5863f5e60535e5c83b52ef..a8fa58bb74a1bd72f165407455c17e1f5e770112 100644 (file)
@@ -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);