]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod-module: Fix return code for kmod_module_new_from_lookup()
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 15 Feb 2022 22:09:14 +0000 (14:09 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 21 Feb 2022 04:58:11 +0000 (20:58 -0800)
When kmod_module_new_from_lookup() resolves to an alias, `err` will be
set to a positive value from the lookup function. Do not return a
positive value to follow the behavior when it matches a module name
and the documentation.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
libkmod/libkmod-module.c

index 64233397555b5ce8b5039a83a8ae1f60cc346bcb..1b59c3c4ef1d3cf3756d77331caa3636452e0bf5 100644 (file)
@@ -589,8 +589,8 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
 
 
 finish:
-       DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list);
-       return err;
+       DBG(ctx, "lookup %s matches=%d, list=%p\n", alias, err, *list);
+       return err > 0 ? 0 : err;
 fail:
        DBG(ctx, "Failed to lookup %s\n", alias);
        kmod_module_unref_list(*list);