diff options
author | Lucas De Marchi <lucas.demarchi@intel.com> | 2022-02-15 14:09:14 -0800 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2022-02-20 20:58:11 -0800 |
commit | ec8818bcfb903c8f6a614a5aa4d1aa231d79308c (patch) | |
tree | d503153610caee641ab3e15491de357f9ef6404c | |
parent | 9dc4e5ccd4d7ff9ed4e96db8446501a3dc862dbf (diff) | |
download | kmod-ec8818bcfb903c8f6a614a5aa4d1aa231d79308c.tar.gz |
libkmod-module: Fix return code for kmod_module_new_from_lookup()
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>
-rw-r--r-- | libkmod/libkmod-module.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 6423339..1b59c3c 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -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); |