From: Vladimír Čunát Date: Fri, 20 Dec 2024 12:27:41 +0000 (+0100) Subject: kr_module_load(): avoid calling deinit() on errors X-Git-Tag: v6.0.10~8^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcb885b5f6e64d2b1714d8553fd12404f67c20e5;p=thirdparty%2Fknot-resolver.git kr_module_load(): avoid calling deinit() on errors If the module's init() failed or wasn't even called, I see it as an API error to call deinit(). When init() fails, it should take care of cleanup itself. --- diff --git a/lib/module.c b/lib/module.c index 79219d3a1..2427c7b6c 100644 --- a/lib/module.c +++ b/lib/module.c @@ -123,6 +123,8 @@ int kr_module_load(struct kr_module *module, const char *name, const char *path) ret = module->init(module); } if (ret != 0) { + /* Avoid calling deinit() as init() wasn't called or failed. */ + module->deinit = NULL; kr_module_unload(module); }