Blame SOURCES/open-lldp-v1.0.1-29-memleak-on-received-TLVs.patch

74731f
From 9b0389837d7532909a8070d5a08f0175c367c12e Mon Sep 17 00:00:00 2001
74731f
From: Chris Leech <cleech@redhat.com>
74731f
Date: Wed, 23 May 2018 16:37:51 -0700
74731f
Subject: [PATCH] memleak on received TLVs from modules
74731f
74731f
Most of the TLV modules that have an rchange handler for received TLVs
74731f
seem to get the return values wrong, returning 0 or TLV_OK without
74731f
freeing or storing the unpacked TLV to be freed later. That leaks the
74731f
allocation, as rxProcessFrame believes the module has claimed ownership.
74731f
74731f
In a test setup, it's probably easiest to see by enabling some TLV type
74731f
on one side of a connection only.  Or, any unexpected TLV that doesn't
74731f
get handled will be erroneously leaked by the EVB modules.
74731f
---
74731f
 lldp_8021qaz.c | 4 ++--
74731f
 lldp_evb.c     | 8 +++++---
74731f
 lldp_evb22.c   | 8 +++++---
74731f
 3 files changed, 12 insertions(+), 8 deletions(-)
74731f
74731f
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
74731f
index 094676d..198ebcf 100644
74731f
--- a/lldp_8021qaz.c
74731f
+++ b/lldp_8021qaz.c
74731f
@@ -1924,7 +1924,7 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
74731f
 	struct ieee8021qaz_unpkd_tlvs *rx;
74731f
 
74731f
 	if (agent->type != NEAREST_BRIDGE)
74731f
-		return 0;
74731f
+		return SUBTYPE_INVALID;
74731f
 
74731f
 	qaz_tlvs = ieee8021qaz_data(port->ifname);
74731f
 	if (!qaz_tlvs)
74731f
@@ -2005,7 +2005,7 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
74731f
 		}
74731f
 	}
74731f
 
74731f
-	return TLV_OK;
74731f
+	return SUBTYPE_INVALID;
74731f
 }
74731f
 
74731f
 static void ieee8021qaz_free_rx(struct ieee8021qaz_unpkd_tlvs *rx)
74731f
diff --git a/lldp_evb.c b/lldp_evb.c
74731f
index 4b3752e..07f5ffb 100644
74731f
--- a/lldp_evb.c
74731f
+++ b/lldp_evb.c
74731f
@@ -210,7 +210,8 @@ static int evb_rchange(struct port *port, struct lldp_agent *agent,
74731f
 	u8 oui_subtype[OUI_SUB_SIZE] = LLDP_OUI_SUBTYPE;
74731f
 
74731f
 	if (agent->type != NEAREST_CUSTOMER_BRIDGE)
74731f
-		return 0;
74731f
+		return SUBTYPE_INVALID;
74731f
+
74731f
 	ed = evb_data(port->ifname, agent->type);
74731f
 
74731f
 	if (!ed)
74731f
@@ -229,7 +230,7 @@ static int evb_rchange(struct port *port, struct lldp_agent *agent,
74731f
 		if (!ed->txmit) {
74731f
 			LLDPAD_WARN("%s:%s agent %d EVB Config disabled\n",
74731f
 				__func__, ed->ifname, agent->type);
74731f
-			return TLV_OK;
74731f
+			return SUBTYPE_INVALID;
74731f
 		}
74731f
 
74731f
 		LLDPAD_DBG("%s:%s agent %d received tlv:\n", __func__,
74731f
@@ -246,7 +247,8 @@ static int evb_rchange(struct port *port, struct lldp_agent *agent,
74731f
 		evb_print_tlvinfo(ed->ifname, &ed->tie);
74731f
 		vdp_update(port->ifname, ed->tie.ccap);
74731f
 	}
74731f
-	return TLV_OK;
74731f
+
74731f
+	return SUBTYPE_INVALID;
74731f
 }
74731f
 
74731f
 /*
74731f
diff --git a/lldp_evb22.c b/lldp_evb22.c
74731f
index 85c6abc..64b04e0 100644
74731f
--- a/lldp_evb22.c
74731f
+++ b/lldp_evb22.c
74731f
@@ -305,7 +305,8 @@ static int evb22_rchange(struct port *port, struct lldp_agent *agent,
74731f
 	u8 oui_subtype[OUI_SUB_SIZE] = LLDP_MOD_EVB22_OUI;
74731f
 
74731f
 	if (agent->type != NEAREST_CUSTOMER_BRIDGE)
74731f
-		return 0;
74731f
+		return SUBTYPE_INVALID;
74731f
+
74731f
 	ed = evb22_data(port->ifname, agent->type);
74731f
 
74731f
 	if (!ed)
74731f
@@ -324,7 +325,7 @@ static int evb22_rchange(struct port *port, struct lldp_agent *agent,
74731f
 		if (!ed->txmit) {
74731f
 			LLDPAD_WARN("%s:%s agent %d EVB Config disabled\n",
74731f
 				__func__, ed->ifname, agent->type);
74731f
-			return TLV_OK;
74731f
+			return SUBTYPE_INVALID;
74731f
 		}
74731f
 
74731f
 		LLDPAD_DBG("%s:%s agent %d received tlv:\n", __func__,
74731f
@@ -341,7 +342,8 @@ static int evb22_rchange(struct port *port, struct lldp_agent *agent,
74731f
 		evb22_print_tlvinfo(ed->ifname, &ed->out);
74731f
 		/* TODO vdp_update(port->ifname, ed->tie.ccap); */
74731f
 	}
74731f
-	return TLV_OK;
74731f
+
74731f
+	return SUBTYPE_INVALID;
74731f
 }
74731f
 
74731f
 /*
74731f
-- 
74731f
2.19.1