diff options
Diffstat (limited to 'src/modules-load/modules-load.c')
-rw-r--r-- | src/modules-load/modules-load.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 6efebcd94f..aaf2927113 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -29,6 +29,7 @@ #include "fd-util.h" #include "fileio.h" #include "log.h" +#include "module-util.h" #include "proc-cmdline.h" #include "string-util.h" #include "strv.h" @@ -77,7 +78,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat static int load_module(struct kmod_ctx *ctx, const char *m) { const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST; - struct kmod_list *itr, *modlist = NULL; + struct kmod_list *itr; + _cleanup_(kmod_module_unref_listp) struct kmod_list *modlist = NULL; int r = 0; log_debug("load: %s", m); @@ -92,7 +94,7 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { } kmod_list_foreach(itr, modlist) { - struct kmod_module *mod; + _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL; int state, err; mod = kmod_module_get_module(itr); @@ -116,16 +118,20 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { else if (err == KMOD_PROBE_APPLY_BLACKLIST) log_info("Module '%s' is blacklisted", kmod_module_get_name(mod)); else { - log_error_errno(err, "Failed to insert '%s': %m", kmod_module_get_name(mod)); - r = err; + assert(err < 0); + + log_full_errno(err == ENODEV ? LOG_NOTICE : + err == ENOENT ? LOG_WARNING : + LOG_ERR, + err, + "Failed to insert '%s': %m", + kmod_module_get_name(mod)); + if (!IN_SET(err, ENODEV, ENOENT)) + r = err; } } - - kmod_module_unref(mod); } - kmod_module_unref_list(modlist); - return r; } @@ -218,7 +224,7 @@ static int parse_argv(int argc, char *argv[]) { int main(int argc, char *argv[]) { int r, k; - struct kmod_ctx *ctx; + _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL; r = parse_argv(argc, argv); if (r <= 0) @@ -280,7 +286,6 @@ int main(int argc, char *argv[]) { } finish: - kmod_unref(ctx); strv_free(arg_proc_cmdline_modules); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; |