chiark / gitweb /
networkd: manager - don't leak kmod context
[elogind.git] / src / network / networkd-manager.c
index cfa3a9900a61a095e3616a8b013e51870cd47ddc..cc55f9a17a0307d74ef9c901c2bc3e0c2cf6bf53 100644 (file)
@@ -118,6 +118,10 @@ int manager_new(Manager **ret) {
                         return -ENOMEM;
         }
 
+        m->kmod_ctx = kmod_new(NULL, NULL);
+        if (!m->kmod_ctx)
+                return -ENOMEM;
+
         m->links = hashmap_new(uint64_hash_func, uint64_compare_func);
         if (!m->links)
                 return -ENOMEM;
@@ -144,6 +148,7 @@ void manager_free(Manager *m) {
 
         free(m->state_file);
 
+        kmod_unref(m->kmod_ctx);
         udev_monitor_unref(m->udev_monitor);
         udev_unref(m->udev);
         sd_bus_unref(m->bus);
@@ -552,18 +557,3 @@ finish:
 
         return r;
 }
-
-int manager_init_kmod_ctx(Manager *m) {
-        struct kmod_ctx *ctx;
-
-        assert(m);
-
-        ctx = kmod_new(NULL, NULL);
-        if (!ctx) {
-                return -ENOMEM;
-        }
-
-        m->kmod_ctx = ctx;
-
-        return 0;
-}