diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-09-30 17:22:11 +0100 |
---|---|---|
committer | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-10-01 10:15:40 +0100 |
commit | a23b80e3d3f18a88630a6f01f06d4e5ba6acec43 (patch) | |
tree | cdced8c6fa4f0c977fe9c67ba0dbab188f0c7afe | |
parent | a1babd3e7560d88209367bc7e3daa1cc43c96fcc (diff) | |
download | module-init-tools-a23b80e3d3f18a88630a6f01f06d4e5ba6acec43.tar.gz |
modprobe: don't run remove commands for modules which are not loaded
modprobe.d(5) strongly suggests you can use remove commands like this:
remove snd-pcm /sbin/modprobe -r --ignore-remove snd-pcm-oss && \
/sbin/modprobe -r snd-pcm
Unfortunately, given that snd-pcm-oss depends on snd-pcm, this causes
an infinite fork-loop.
The solution is an exact parallel of the approach taken for install
commands. AFAIK no-one uses remove commands, but it's good to make
the insmod() and rmmod() functions consistent.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
-rw-r--r-- | modprobe.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1293,6 +1293,10 @@ static void rmmod(struct list_head *list, if (!name) name = mod->modname; + /* Don't do ANYTHING if not loaded. */ + if (module_in_kernel(name, &usecount) == 0) + goto nonexistent_module; + /* Even if renamed, find commands to orig. name. */ command = find_command(mod->modname, commands); if (command && !(flags & mit_ignore_commands)) { @@ -1301,9 +1305,6 @@ static void rmmod(struct list_head *list, goto remove_rest; } - if (module_in_kernel(name, &usecount) == 0) - goto nonexistent_module; - if (usecount != 0) { if (!(flags & mit_ignore_loaded)) error("Module %s is in use.\n", name); |