diff options
author | Renato Westphal <renato@cvs.openbsd.org> | 2016-06-18 17:13:06 +0000 |
---|---|---|
committer | Renato Westphal <renato@cvs.openbsd.org> | 2016-06-18 17:13:06 +0000 |
commit | 9bd1599b3b41e7a556919282bec4e8dd2ff56b51 (patch) | |
tree | 28cd945791a603c7be8e8dc662ec43a4ec85a773 | |
parent | 68c2a6fad0bd8b003e6d4a985d0adefe97ed2953 (diff) |
Fix memory leak found with valgrind.
-rw-r--r-- | usr.sbin/ldpd/l2vpn.c | 11 | ||||
-rw-r--r-- | usr.sbin/ldpd/lde.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/ldpd.c | 7 |
3 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/ldpd/l2vpn.c b/usr.sbin/ldpd/l2vpn.c index 2384e49f36b..4a8d46c932d 100644 --- a/usr.sbin/ldpd/l2vpn.c +++ b/usr.sbin/ldpd/l2vpn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: l2vpn.c,v 1.17 2016/06/18 01:25:53 renato Exp $ */ +/* $OpenBSD: l2vpn.c,v 1.18 2016/06/18 17:13:05 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -91,6 +91,15 @@ l2vpn_init(struct l2vpn *l2vpn) l2vpn_pw_init(pw); } +void +l2vpn_exit(struct l2vpn *l2vpn) +{ + struct l2vpn_pw *pw; + + LIST_FOREACH(pw, &l2vpn->pw_list, entry) + l2vpn_pw_exit(pw); +} + struct l2vpn_if * l2vpn_if_new(struct l2vpn *l2vpn, struct kif *kif) { diff --git a/usr.sbin/ldpd/lde.h b/usr.sbin/ldpd/lde.h index b30c28965e1..d882d77c0e8 100644 --- a/usr.sbin/ldpd/lde.h +++ b/usr.sbin/ldpd/lde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lde.h,v 1.40 2016/06/18 01:25:53 renato Exp $ */ +/* $OpenBSD: lde.h,v 1.41 2016/06/18 17:13:05 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -182,6 +182,7 @@ struct l2vpn *l2vpn_new(const char *); struct l2vpn *l2vpn_find(struct ldpd_conf *, const char *); void l2vpn_del(struct l2vpn *); void l2vpn_init(struct l2vpn *); +void l2vpn_exit(struct l2vpn *); struct l2vpn_if *l2vpn_if_new(struct l2vpn *, struct kif *); struct l2vpn_if *l2vpn_if_find(struct l2vpn *, unsigned int); struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, struct kif *); diff --git a/usr.sbin/ldpd/ldpd.c b/usr.sbin/ldpd/ldpd.c index 15cdf4994c3..9ef1e63d2a6 100644 --- a/usr.sbin/ldpd/ldpd.c +++ b/usr.sbin/ldpd/ldpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpd.c,v 1.53 2016/06/18 01:30:28 renato Exp $ */ +/* $OpenBSD: ldpd.c,v 1.54 2016/06/18 17:13:05 renato Exp $ */ /* * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org> @@ -1030,16 +1030,15 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf) switch (ldpd_process) { case PROC_LDE_ENGINE: - l2vpn_del(l2vpn); + l2vpn_exit(l2vpn); break; case PROC_LDP_ENGINE: ldpe_l2vpn_exit(l2vpn); - free(l2vpn); break; case PROC_MAIN: - free(l2vpn); break; } + l2vpn_del(l2vpn); } } LIST_FOREACH_SAFE(xl, &xconf->l2vpn_list, entry, ltmp) { |