summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-05-12 17:11:13 +0200
committerTom Gundersen <teg@jklm.no>2014-05-12 17:37:58 +0200
commit0b44d8c3d7dfadb60b30c9339b18c4cc1617b51b (patch)
tree5e6207335195e8028da3976dad330c1a25e90aaa /src
parent7c8ec321e7b6fd97a6eb4b9a3daa16c51b97a74a (diff)
networkd: manager - don't leak kmod context
Also, keep the kmod_new internal to networkd-manager.c
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/network-internal.c2
-rw-r--r--src/network/networkd-manager.c20
-rw-r--r--src/network/networkd.c6
-rw-r--r--src/network/networkd.h1
4 files changed, 7 insertions, 22 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c
index cf577e54a4..f3dc42f6dd 100644
--- a/src/libsystemd-network/network-internal.c
+++ b/src/libsystemd-network/network-internal.c
@@ -353,6 +353,8 @@ int load_module(struct kmod_ctx *ctx, const char *mod_name) {
log_error("Failed to insert '%s': %s", kmod_module_get_name(mod),
strerror(-r));
}
+
+ kmod_module_unref(mod);
}
kmod_module_unref_list(modlist);
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index cfa3a9900a..cc55f9a17a 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -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;
-}
diff --git a/src/network/networkd.c b/src/network/networkd.c
index 39e1b2af02..6b3bf12a4c 100644
--- a/src/network/networkd.c
+++ b/src/network/networkd.c
@@ -87,12 +87,6 @@ int main(int argc, char *argv[]) {
goto out;
}
- r = manager_init_kmod_ctx(m);
- if (r < 0) {
- log_error("Could not init kmod context: %s", strerror(-r));
- goto out;
- }
-
r = manager_rtnl_enumerate_links(m);
if (r < 0) {
log_error("Could not enumerate links: %s", strerror(-r));
diff --git a/src/network/networkd.h b/src/network/networkd.h
index e32cf5d9b2..11d0056c9c 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -277,7 +277,6 @@ int manager_bus_listen(Manager *m);
int manager_update_resolv_conf(Manager *m);
int manager_save(Manager *m);
-int manager_init_kmod_ctx(Manager *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
#define _cleanup_manager_free_ _cleanup_(manager_freep)