From 4e624dc2f10a821221a4497f564371d12b229aa2 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 2 Jun 2009 10:57:15 +0200 Subject: [PATCH] Don't free statically allocated port. --- src/cdp.c | 1 + src/edp.c | 1 + src/lldp.c | 1 + src/lldpd.c | 6 +++--- src/sonmp.c | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cdp.c b/src/cdp.c index e3c18ffa..0f3df5c5 100644 --- a/src/cdp.c +++ b/src/cdp.c @@ -466,6 +466,7 @@ cdp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis, 1); lldpd_port_cleanup(port, 1); + free(port); return -1; } diff --git a/src/edp.c b/src/edp.c index b9197ed3..7a628b9d 100644 --- a/src/edp.c +++ b/src/edp.c @@ -483,6 +483,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis, 1); lldpd_port_cleanup(port, 1); + free(port); return -1; } diff --git a/src/lldp.c b/src/lldp.c index 5aa9deee..3fd56472 100644 --- a/src/lldp.c +++ b/src/lldp.c @@ -784,5 +784,6 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis, 1); lldpd_port_cleanup(port, 1); + free(port); return -1; } diff --git a/src/lldpd.c b/src/lldpd.c index ee3ce70d..16c757bc 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -150,8 +150,7 @@ lldpd_vlan_cleanup(struct lldpd_port *port) #endif /* If `all' is true, clear all information, including information that - are not refreshed periodically. If `all' is true, also free the - port. */ + are not refreshed periodically. Port should be freed manually. */ void lldpd_port_cleanup(struct lldpd_port *port, int all) { @@ -170,7 +169,6 @@ lldpd_port_cleanup(struct lldpd_port *port, int all) free(port->p_lastframe); if (port->p_chassis) /* chassis may not have been attributed, yet */ port->p_chassis->c_refcount--; - free(port); } } @@ -211,6 +209,7 @@ lldpd_remote_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware, int all if (del) { TAILQ_REMOVE(&hardware->h_rports, port, p_entries); lldpd_port_cleanup(port, 1); + free(port); } } } @@ -344,6 +343,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s, /* The port is known, remove it before adding it back */ TAILQ_REMOVE(&hardware->h_rports, oport, p_entries); lldpd_port_cleanup(oport, 1); + free(oport); } if (ochassis) { lldpd_update_chassis(ochassis, chassis); diff --git a/src/sonmp.c b/src/sonmp.c index cb201fb1..ed09c77d 100644 --- a/src/sonmp.c +++ b/src/sonmp.c @@ -378,6 +378,7 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s, malformed: lldpd_chassis_cleanup(chassis, 1); lldpd_port_cleanup(port, 1); + free(port); return -1; } -- 2.39.5