]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Remove module from hash when it's gone
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 15 Dec 2011 15:43:22 +0000 (13:43 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 15 Dec 2011 15:49:13 +0000 (13:49 -0200)
Module was never being removed from hash table. Therefore, if we create
a module, unref it and create it again we will access freed memory.
Commit "53385cf Improve test of double references" introduced a new test
in test-mod-double-ref.c that previously to this commit was crashing and
now it's working fine.

libkmod/libkmod-module.c

index 79a49c3489d1ff743f21cd9abf84067539886c10..6b6911bb7f30619471c43fd5d4cdd91d8bd3048f 100644 (file)
@@ -392,6 +392,7 @@ KMOD_EXPORT struct kmod_module *kmod_module_unref(struct kmod_module *mod)
 
        DBG(mod->ctx, "kmod_module %p released\n", mod);
 
+       kmod_pool_del_module(mod->ctx, mod, mod->hashkey);
        kmod_module_unref_list(mod->dep);
        kmod_unref(mod->ctx);
        free(mod->options);