From: Gustavo Sverzut Barbieri Date: Sun, 4 Dec 2011 23:18:21 +0000 (-0200) Subject: tests: release memory before error exits. X-Git-Tag: v1~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8226058343ac9634b9af0999c9fce84dc71e1bb9;p=thirdparty%2Fkmod.git tests: release memory before error exits. this makes it easier to valgrind the error cases as well. --- diff --git a/test/test-insmod.c b/test/test-insmod.c index bbff8784..fb585619 100644 --- a/test/test-insmod.c +++ b/test/test-insmod.c @@ -29,8 +29,10 @@ int main(int argc, char *argv[]) printf("libkmod version %s\n", VERSION); err = kmod_module_new_from_path(ctx, path, &mod); - if (err < 0) + if (err < 0) { + kmod_unref(ctx); exit(EXIT_FAILURE); + } printf("Trying insmod '%s'\n", path); err = kmod_module_insert_module(mod, 0); diff --git a/test/test-lookup.c b/test/test-lookup.c index 29a7d3c9..5b276288 100644 --- a/test/test-lookup.c +++ b/test/test-lookup.c @@ -40,6 +40,7 @@ int main(int argc, char *argv[]) kmod_list_foreach(l, list) { struct kmod_module *mod = kmod_module_get_module(l); printf("\t%s\n", kmod_module_get_name(mod)); + kmod_module_unref(mod); } kmod_module_unref_list(list); diff --git a/test/test-rmmod.c b/test/test-rmmod.c index 7a7bc5b4..e1b9fb4f 100644 --- a/test/test-rmmod.c +++ b/test/test-rmmod.c @@ -27,6 +27,7 @@ int main(int argc, char *argv[]) err = kmod_loaded_get_list(ctx, &list); if (err < 0) { fprintf(stderr, "%s\n", strerror(-err)); + kmod_unref(ctx); exit(EXIT_FAILURE); } diff --git a/test/test-rmmod2.c b/test/test-rmmod2.c index c3585be5..5e3fa496 100644 --- a/test/test-rmmod2.c +++ b/test/test-rmmod2.c @@ -29,8 +29,10 @@ int main(int argc, char *argv[]) printf("libkmod version %s\n", VERSION); err = kmod_module_new_from_name(ctx, modname, &mod); - if (err < 0) + if (err < 0) { + kmod_unref(ctx); exit(EXIT_FAILURE); + } printf("Trying to remove '%s'\n", modname); kmod_module_remove_module(mod, 0);