]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Fix a memory leak that can happen when a port is removed or renamed
authorVincent Bernat <vbernat.ext@orange-ftgroup.com>
Fri, 27 Feb 2009 12:46:02 +0000 (13:46 +0100)
committerVincent Bernat <vbernat.ext@orange-ftgroup.com>
Fri, 27 Feb 2009 12:46:02 +0000 (13:46 +0100)
src/cdp.c
src/edp.c
src/lldp.c
src/lldpd.c
src/sonmp.c

index 55c6622445bed374b517d810bb763bf7172d0484..3581e39852efae9c0cb7b476d73d48ffe7aff953 100644 (file)
--- a/src/cdp.c
+++ b/src/cdp.c
@@ -493,6 +493,7 @@ cdp_decode(struct lldpd *cfg, char *frame, int s,
 malformed:
        lldpd_chassis_cleanup(chassis);
        lldpd_port_cleanup(port);
+       free(port);
        return -1;
 }
 
index 641845557f9bf5df578082aecca8f5562c6552d8..0e2e525742a3033e91021a911322940cab31e0b7 100644 (file)
--- a/src/edp.c
+++ b/src/edp.c
@@ -482,6 +482,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s,
 malformed:
        lldpd_chassis_cleanup(chassis);
        lldpd_port_cleanup(port);
+       free(port);
        return -1;
 }
 
index 004ddda4aeb9097dadba43404078485088c34024..172d9b4c75da43398a10afff2ebcf1091e456fa3 100644 (file)
@@ -973,5 +973,6 @@ lldp_decode(struct lldpd *cfg, char *frame, int s,
 malformed:
        lldpd_chassis_cleanup(chassis);
        lldpd_port_cleanup(port);
+       free(port);
        return -1;
 }
index d1d996d92be6e5f293f3a1fad7bc9f5b82116808..e6d16e4dcc77e6986f211968d48a6597da43c215 100644 (file)
@@ -378,7 +378,8 @@ lldpd_port_cleanup(struct lldpd_port *port)
 #endif
        free(port->p_id);
        free(port->p_descr);
-       free(port);
+       /* Don't free port, we may use this function on statically
+          allocated ports */
 }
 
 void
@@ -404,6 +405,7 @@ lldpd_remote_cleanup(struct lldpd *cfg, struct lldpd_hardware *hardware, int res
 {
        if (hardware->h_rport != NULL) {
                lldpd_port_cleanup(hardware->h_rport);
+               free(hardware->h_rport);
                hardware->h_rport = NULL;
        }
        if (hardware->h_rchassis != NULL) {
@@ -427,6 +429,7 @@ lldpd_hardware_cleanup(struct lldpd_hardware *hardware)
 #ifdef ENABLE_DOT1
        lldpd_vlan_cleanup(&hardware->h_lport);
 #endif
+       lldpd_port_cleanup(&hardware->h_lport);
        free(hardware->h_proto_macs);
        free(hardware->h_llastframe);
        free(hardware);
@@ -976,6 +979,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 cleanup:
        lldpd_chassis_cleanup(chassis);
        lldpd_port_cleanup(port);
+       free(port);
        return;
 }
 
index cccce6798f1d856805185604035813b486197310..ed8ba737bcd9b230d33a5ad0ac4203caecc053b1 100644 (file)
@@ -331,6 +331,7 @@ sonmp_decode(struct lldpd *cfg, char *frame, int s,
 malformed:
        lldpd_chassis_cleanup(chassis);
        lldpd_port_cleanup(port);
+       free(port);
        return -1;
 }