]> git.ipfire.org Git - thirdparty/kmod.git/commit
modprobe: Fix holders removal
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 29 Mar 2022 09:05:37 +0000 (02:05 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 7 Apr 2022 05:03:59 +0000 (22:03 -0700)
commit42b32d30c38ef032f287957266a022eb28430bfc
treecbdf9ae9e5206a2515757e49704654c5ec0aa3be
parentd890179b451211c506b7860f125a6ae181c9f5dc
modprobe: Fix holders removal

The idea behind --remove-dependencies was to remove other modules that
depend on the current module being removed. It's the reverse
dependency list, not the dependency list of the current module: that
never works since the current module would still hold a ref on it.

Fix it by replacing the call to kmod_module_get_dependencies() with
kmod_module_get_holders() when using that option. Also try to cleanup
the confusion by renaming the option to --remove-holders: "holder" is
the name used in sysfs and by libkmod to refer to a "live" reverse
dependency like what we are interested in.

Before:
./tools/modprobe -D -r --remove-dependencies video
rmmod video

After:
./tools/modprobe -D -r --remove-holders video
rmmod i915
rmmod thinkpad_acpi
rmmod video

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
tools/modprobe.c