]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Fix refcount of loaded modules
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 24 Nov 2011 17:41:15 +0000 (15:41 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 24 Nov 2011 17:41:15 +0000 (15:41 -0200)
libkmod/libkmod-loaded.c

index 7698af9db06768cbbba6ad1bff19e0c86c501f49..1333f3ccca96094b20af9391519384f97179d448 100644 (file)
@@ -99,7 +99,10 @@ KMOD_EXPORT struct kmod_loaded *kmod_loaded_unref(struct kmod_loaded *mod)
 {
        if (mod == NULL)
                return NULL;
-       mod->refcount--;
+
+       if (--mod->refcount > 0)
+               return mod;
+
        dbg(mod->ctx, "kmod_loaded %p released\n", mod);
        loaded_modules_free(mod);
        free(mod);