]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: Fix init_module
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 18 Sep 2024 19:53:23 +0000 (21:53 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sat, 21 Sep 2024 15:51:01 +0000 (10:51 -0500)
Apply same logic as in delete_module.c, i.e. pass a reference to a
pointer instead of the pointer value, otherwise we cannot update
the linked list and added entries are lost.

Spotted with ASAN while running testsuite.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/141
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/init_module.c

index d842ace0dbc77e7711f1b0da4a2b22d516700545..b6ac1c2d1b4f266f367987f72e6cb7a2044fbff3 100644 (file)
@@ -48,7 +48,7 @@ static struct mod *modules;
 static bool need_init = true;
 static struct kmod_ctx *ctx;
 
-static void parse_retcodes(struct mod *_modules, const char *s)
+static void parse_retcodes(struct mod **_modules, const char *s)
 {
        const char *p;
 
@@ -97,8 +97,8 @@ static void parse_retcodes(struct mod *_modules, const char *s)
                mod->name[modnamelen] = '\0';
                mod->ret = ret;
                mod->errcode = errcode;
-               mod->next = _modules;
-               _modules = mod;
+               mod->next = *_modules;
+               *_modules = mod;
        }
 }
 
@@ -179,7 +179,7 @@ static void init_retcodes(void)
 
        ctx = kmod_new(NULL, NULL);
 
-       parse_retcodes(modules, s);
+       parse_retcodes(&modules, s);
 }
 
 static inline bool module_is_inkernel(const char *modname)