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