In a scenario like following:
# lsmod | grep -e bnx2i -e cnic
bnx2i 94208 0
libiscsi 94208 1 bnx2i
cnic 90112 1 bnx2i
uio 32768 1 cnic
scsi_transport_iscsi 196608 2 bnx2i,libiscsi
# modprobe -v --remove --remove-holders cnic
rmmod bnx2i
rmmod cnic
rmmod libiscsi
rmmod cnic
modprobe: ERROR: libkmod/libkmod-module.c:856 kmod_module_remove_module()
could not remove 'cnic': No such file or directory
modprobe attempts to remove cnic module twice and propagates that error
to the user with a message as well as an exit code.
Add a check to avoid attempts to remove modules that are already gone.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/pull/393
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
}
}
- if (!cmd)
- err = rmmod_do_remove_module(mod);
- else
+ if (!cmd) {
+ if (kmod_module_get_refcnt(mod) != -ENOENT)
+ err = rmmod_do_remove_module(mod);
+ else
+ err = 0;
+ } else
err = command_do(mod, "remove", cmd, NULL);
if (err < 0)