From 95dd837daf5d03d52ad37fdb6ee603bffb114419 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 20 Dec 2011 13:11:33 -0200 Subject: [PATCH] kmod_modprobe: Fix regression when inserting module Commit "e5e2a68 kmod_modprobe: properly handle install/remove commands" introduced a regression that, while it worked for install/remove commands, it ceased to work for normal module names. Move the check for whether it's a install command or a module so both cases work. --- tools/kmod-modprobe.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c index 7f069da9..f78a7ac2 100644 --- a/tools/kmod-modprobe.c +++ b/tools/kmod-modprobe.c @@ -740,10 +740,7 @@ static int insmod_do(struct kmod_module *mod, const char *extra_opts) if (!ignore_loaded) { int state = kmod_module_get_initstate(mod); - if (state < 0) { - LOG("Module %s not found.\n", modname); - return -ENOENT; - } else if (state == KMOD_MODULE_BUILTIN) { + if (state == KMOD_MODULE_BUILTIN) { if (first_time) { LOG("Module %s already in kernel (builtin).\n", modname); @@ -759,6 +756,16 @@ static int insmod_do(struct kmod_module *mod, const char *extra_opts) } } + /* + * At this point it's not possible to be a install/remove command + * anymore. So if we can't get module's path, it's because it was + * really intended to be a module and it doesn't exist + */ + if (kmod_module_get_path(mod) == NULL) { + LOG("Module %s not found.\n", modname); + return -ENOENT; + } + err = insmod_do_dependencies(mod); if (err < 0) return err; -- 2.47.2