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;
}