]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite/test-init: plug memory leaks in success path
authorEmil Velikov <emil.l.velikov@gmail.com>
Fri, 13 Jun 2025 19:12:28 +0000 (20:12 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 16 Jun 2025 12:37:42 +0000 (07:37 -0500)
With the upcoming patches, removing exit() usage, ASan started reporting
that our test leaks kmod_module handles.

Resolve those leaks - we shouldn't be doing that in the normal (success)
path.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/test-init.c

index d9b8f3af68005a8d5081b6112e0b5ef661ff80b7..a1523dbe087e4300d3927bbdfbb2f908e0c31136 100644 (file)
@@ -95,6 +95,7 @@ static noreturn int test_insert(void)
                ERR("could not insert module: %s\n", strerror(-err));
                exit(EXIT_FAILURE);
        }
+       kmod_module_unref(mod);
        kmod_unref(ctx);
 
        exit(EXIT_SUCCESS);
@@ -142,6 +143,8 @@ static noreturn int test_remove(void)
                exit(EXIT_FAILURE);
        }
 
+       kmod_module_unref(mod_bla);
+       kmod_module_unref(mod_simple);
        kmod_unref(ctx);
 
        exit(EXIT_SUCCESS);