mirror of
https://github.com/AuxXxilium/kmod.git
synced 2024-12-28 06:15:20 +07:00
modprobe: properly handle errors from init_module
Effectively catch and the zero and non-zero cases and error out appropriately. Note that -EEXIST will only ever be returned when KMOD_PROBE_STOP_ON_ALREADY_LOADED is set as a probe_insert_module flag.
This commit is contained in:
parent
7aed46088e
commit
297a3182e4
@ -590,10 +590,21 @@ static int insmod(struct kmod_ctx *ctx, const char *alias,
|
||||
extra_options, NULL, NULL, show);
|
||||
}
|
||||
|
||||
if (err == KMOD_PROBE_STOP_ON_ALREADY_LOADED) {
|
||||
ERR("Module %s already in kernel.\n",
|
||||
kmod_module_get_name(mod));
|
||||
err = -EEXIST;
|
||||
if (err >= 0)
|
||||
/* ignore flag return values such as a mod being blacklisted */
|
||||
err = 0;
|
||||
else {
|
||||
switch (err) {
|
||||
case -EEXIST:
|
||||
ERR("could not insert '%s': Module already in kernel\n",
|
||||
kmod_module_get_name(mod));
|
||||
break;
|
||||
default:
|
||||
ERR("could not insert '%s': %s\n",
|
||||
kmod_module_get_name(mod),
|
||||
strerror(-err));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
kmod_module_unref(mod);
|
||||
|
Loading…
Reference in New Issue
Block a user