]> git.ipfire.org Git - thirdparty/kmod.git/blobdiff - libkmod/libkmod-module.c
kmod_module: treat module creation by path with same names
[thirdparty/kmod.git] / libkmod / libkmod-module.c
index 0aee3eef903fb83c1a74f5c99ff0b727fc9cd1c2..3acd5b0c95317052ef2b85006bbe8a37220744c1 100644 (file)
@@ -202,7 +202,17 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
 
        m = kmod_pool_get_module(ctx, name);
        if (m != NULL) {
-               free(abspath);
+               if (m->path == NULL)
+                       m->path = abspath;
+               else if (streq(m->path, abspath))
+                       free(abspath);
+               else {
+                       ERR(ctx, "kmod_module '%s' already exists with different path\n",
+                                                                       name);
+                       free(abspath);
+                       return -EEXIST;
+               }
+
                *mod = kmod_module_ref(m);
                return 0;
        }