From: Emil Velikov Date: Thu, 3 Oct 2024 15:27:37 +0000 (+0100) Subject: libkmod: unref in kmod_module_new_from_path() error path X-Git-Tag: v34~267 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2043c657959b71ffe36efbf5fe2ab27edd4ad246;p=thirdparty%2Fkmod.git libkmod: unref in kmod_module_new_from_path() error path Preserve the original behaviour, where the module refcount stays the same, if the function fails. Fixes: e19338da ("libkmod: Avoid redundant kmod_pool_get_module call") Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/171 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 1a7c39a5..bdb8082e 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -350,6 +350,7 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx, const char *path else if (streq(m->path, abspath)) free(abspath); else { + kmod_module_unref(m); ERR(ctx, "kmod_module '%s' already exists with different path: new-path='%s' old-path='%s'\n", name, abspath, m->path);