]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Ref and unref ctx when kmod_loaded is created/destroyed
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 25 Nov 2011 01:06:48 +0000 (23:06 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 25 Nov 2011 01:09:39 +0000 (23:09 -0200)
libkmod/libkmod-loaded.c

index 1333f3ccca96094b20af9391519384f97179d448..f209a790ef06914ed60d16c8cd6a684c662e68de 100644 (file)
@@ -67,7 +67,7 @@ KMOD_EXPORT int kmod_loaded_new(struct kmod_ctx *ctx, struct kmod_loaded **mod)
                return -ENOMEM;
 
        m->refcount = 1;
-       m->ctx = ctx;
+       m->ctx = kmod_ref(ctx);
        *mod = m;
        return 0;
 }
@@ -104,6 +104,8 @@ KMOD_EXPORT struct kmod_loaded *kmod_loaded_unref(struct kmod_loaded *mod)
                return mod;
 
        dbg(mod->ctx, "kmod_loaded %p released\n", mod);
+
+       kmod_unref(mod->ctx);
        loaded_modules_free(mod);
        free(mod);
        return NULL;