From: Lucas De Marchi Date: Tue, 20 Dec 2011 15:11:33 +0000 (-0200) Subject: kmod_modprobe: Fix regression when inserting module X-Git-Tag: v2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95dd837daf5d03d52ad37fdb6ee603bffb114419;p=thirdparty%2Fkmod.git 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. --- 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;