From 5611bf6eb2d23e30378225e8aaeb1cf162197620 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Fri, 13 Jun 2025 20:12:28 +0100 Subject: [PATCH] testsuite/test-init: plug memory leaks in success path 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 Link: https://github.com/kmod-project/kmod/pull/371 Signed-off-by: Lucas De Marchi --- testsuite/test-init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testsuite/test-init.c b/testsuite/test-init.c index d9b8f3af..a1523dbe 100644 --- a/testsuite/test-init.c +++ b/testsuite/test-init.c @@ -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); -- 2.47.2