modprobe: post-remove module deps with 0 refcnt

This commit looks shockingly similar to 0e9bd2d1 because SOMEONE decided
to remove it in a872bba in a glorious frenzy of refactoring.
This commit is contained in:
Dave Reisner 2012-01-30 17:16:50 -05:00 committed by Lucas De Marchi
parent 2e9dcd742e
commit 69a1974347

View File

@ -339,6 +339,7 @@ end:
static int rmmod_do_remove_module(struct kmod_module *mod)
{
const char *modname = kmod_module_get_name(mod);
struct kmod_list *deps, *itr;
int flags = 0, err;
SHOW("rmmod %s\n", kmod_module_get_name(mod));
@ -357,6 +358,17 @@ static int rmmod_do_remove_module(struct kmod_module *mod)
LOG("Module %s is not in kernel.\n", modname);
}
deps = kmod_module_get_dependencies(mod);
if (deps != NULL) {
kmod_list_foreach(itr, deps) {
struct kmod_module *dep = kmod_module_get_module(itr);
if (kmod_module_get_refcnt(dep) == 0)
rmmod_do_remove_module(dep);
kmod_module_unref(dep);
}
kmod_module_unref_list(deps);
}
return err;
}