]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: unref in kmod_module_new_from_path() error path
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 3 Oct 2024 15:27:37 +0000 (16:27 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 9 Oct 2024 03:56:29 +0000 (22:56 -0500)
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 <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/171
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-module.c

index 1a7c39a5ab8999965ae4726ed3ddea2e36389826..bdb8082e2ffdff7eaa7e1da75e27f8fca992ebfd 100644 (file)
@@ -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);