From: Lucas De Marchi Date: Thu, 15 Dec 2011 15:43:22 +0000 (-0200) Subject: Remove module from hash when it's gone X-Git-Tag: v1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4084c176c1504397d0f66bd404799f7b2da92058;p=thirdparty%2Fkmod.git Remove module from hash when it's gone 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. --- diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 79a49c34..6b6911bb 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -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);