This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/2242
sigtran: fix various memory leaks (msgb and xua_msg)
Change-Id: I708505d129da5824c69b31a13a9c93201929bada
---
M examples/sccp_test_server.c
M examples/sccp_test_vty.c
M src/osmo_ss7_hmrt.c
M src/sccp_scrc.c
M src/sccp_user.c
5 files changed, 56 insertions(+), 18 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/42/2242/1
diff --git a/examples/sccp_test_server.c b/examples/sccp_test_server.c
index c3c658f..71bed96 100644
--- a/examples/sccp_test_server.c
+++ b/examples/sccp_test_server.c
@@ -34,6 +34,7 @@
oph->primitive, oph->operation);
break;
}
+ msgb_free(oph->msg);
return 0;
}
@@ -71,6 +72,7 @@
oph->primitive, oph->operation);
break;
}
+ msgb_free(oph->msg);
return 0;
}
@@ -102,6 +104,7 @@
oph->primitive, oph->operation);
break;
}
+ msgb_free(oph->msg);
return 0;
}
diff --git a/examples/sccp_test_vty.c b/examples/sccp_test_vty.c
index 1134d57..ddfbb27 100644
--- a/examples/sccp_test_vty.c
+++ b/examples/sccp_test_vty.c
@@ -125,6 +125,7 @@
default:
break;
}
+ msgb_free(oph->msg);
return 0;
}
diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c
index bc2b8e5..7269f93 100644
--- a/src/osmo_ss7_hmrt.c
+++ b/src/osmo_ss7_hmrt.c
@@ -108,6 +108,7 @@
default:
LOGP(DLSS7, LOGL_ERROR, "Unknown M3UA XFER Message "
"Type %u\n", xua->hdr.msg_type);
+ xua_msg_free(xua);
return -1;
}
break;
@@ -119,6 +120,7 @@
/* Discard Message */
LOGP(DLSS7, LOGL_ERROR, "Unknown M3UA Message Class %u\n",
xua->hdr.msg_class);
+ xua_msg_free(xua);
return -1;
}
@@ -130,6 +132,7 @@
LOGP(DLSS7, LOGL_NOTICE, "No MTP-User for SI %u\n", service_ind);
/* Discard Message */
/* FIXME: User Part Unavailable HMDT -> HMRT */
+ xua_msg_free(xua);
return -1;
}
}
@@ -174,6 +177,7 @@
/* Message Received for inaccesible SP HMRT ->RTPC */
/* Discard Message */
}
+ xua_msg_free(xua);
return -1;
}
@@ -195,6 +199,7 @@
struct osmo_mtp_prim *omp)
{
struct xua_msg *xua;
+ int rc;
OSMO_ASSERT(omp->oph.sap == MTP_SAP_USER);
@@ -210,10 +215,13 @@
* is a very useful feature (aka "loopback device" in
* IPv4). So we call m3ua_hmdc_rx_from_l2() just like
* the MTP-TRANSFER had been received from L2. */
- return m3ua_hmdc_rx_from_l2(inst, xua);
+ rc = m3ua_hmdc_rx_from_l2(inst, xua);
default:
LOGP(DLSS7, LOGL_ERROR, "Ignoring unknown primitive %u:%u\n",
omp->oph.primitive, omp->oph.operation);
- return -1;
+ rc = -1;
}
+
+ msgb_free(omp->oph.msg);
+ return rc;
}
diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c
index 0ab25cb..88aed59 100644
--- a/src/sccp_scrc.c
+++ b/src/sccp_scrc.c
@@ -374,20 +374,29 @@
struct xua_msg *xua)
{
struct osmo_sccp_addr called;
+ int rc;
LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua));
sua_addr_parse(&called, xua, SUA_IEI_DEST_ADDR);
/* Is this a CR message ? */
- if (xua->hdr.msg_type != SUA_CO_CORE)
- return scrc_node_2(inst, xua, &called);
+ if (xua->hdr.msg_type != SUA_CO_CORE) {
+ rc = scrc_node_2(inst, xua, &called);
+ goto out;
+ }
/* TOOD: Coupling performed (not supported) */
- if (0)
- return scrc_node_2(inst, xua, &called);
+ if (0) {
+ rc = scrc_node_2(inst, xua, &called);
+ goto out;
+ }
- return scrc_local_out_common(inst, xua, &called);
+ rc = scrc_local_out_common(inst, xua, &called);
+
+out:
+ xua_msg_free(xua);
+ return rc;
}
/* Connectionless Message SCLC -> SCRC */
@@ -395,6 +404,7 @@
struct xua_msg *xua)
{
struct osmo_sccp_addr called;
+ int rc;
LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua));
@@ -403,16 +413,23 @@
/* Message Type */
if (xua->hdr.msg_type == SUA_CL_CLDR) {
/* UDTS, XUDTS or LUDTS */
- if (called.ri != OSMO_SCCP_RI_GT)
- return scrc_node_7(inst, xua, &called);
+ if (called.ri != OSMO_SCCP_RI_GT) {
+ rc = scrc_node_7(inst, xua, &called);
+ goto out;
+ }
/* Fall-through */
} else {
if (0 /* TODO: translation already performed */) {
/* Node 12 (Sheet 5) */
- return scrc_node_12(inst, xua, &called);
+ rc = scrc_node_12(inst, xua, &called);
+ goto out;
}
}
- return scrc_local_out_common(inst, xua, &called);
+
+ rc = scrc_local_out_common(inst, xua, &called);
+out:
+ xua_msg_free(xua);
+ return rc;
}
/* Figure C.1/Q.714 Sheet 1 of 12, after we converted the
@@ -423,6 +440,7 @@
struct osmo_sccp_addr called;
uint32_t proto_class;
struct xua_msg_part *hop_ctr_part;
+ int rc;
LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua));
/* TODO: SCCP or nodal congestion? */
@@ -432,7 +450,8 @@
/* Node 1 (Sheet 3) */
/* deliver to SCOC */
sccp_scoc_rx_from_scrc(inst, xua);
- return 0;
+ rc = 0;
+ goto out;
}
/* We only treat connectionless and CR below */
@@ -441,7 +460,8 @@
/* Route on GT? */
if (called.ri != OSMO_SCCP_RI_GT) {
/* Node 6 (Sheet 3) */
- return scrc_node_6(inst, xua, &called);
+ rc = scrc_node_6(inst, xua, &called);
+ goto out;
}
/* Message with hop-counter? */
hop_ctr_part = xua_msg_find_tag(xua, SUA_IEI_S7_HOP_CTR);
@@ -450,8 +470,8 @@
if (hop_counter <= 1) {
/* Error: hop-counter violation */
/* node 4 */
- return scrc_node_4(inst, xua,
- SCCP_RETURN_CAUSE_HOP_COUNTER_VIOLATION);
+ rc = scrc_node_4(inst, xua, SCCP_RETURN_CAUSE_HOP_COUNTER_VIOLATION);
+ goto out;
}
/* Decrement hop-counter */
hop_counter--;
@@ -471,5 +491,8 @@
default:
break;
}
- return scrc_translate_node_9(inst, xua, &called);
+ rc = scrc_translate_node_9(inst, xua, &called);
+out:
+ xua_msg_free(xua);
+ return rc;
}
diff --git a/src/sccp_user.c b/src/sccp_user.c
index 5c8d026..825d545 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -152,6 +152,7 @@
struct osmo_sccp_instance *inst = ctx;
struct osmo_mtp_prim *omp = (struct osmo_mtp_prim *)oph;
struct xua_msg *xua;
+ int rc;
OSMO_ASSERT(oph->sap == MTP_SAP_USER);
@@ -161,12 +162,14 @@
xua = osmo_sccp_to_xua(oph->msg);
xua->mtp = omp->u.transfer;
/* hand this primitive into SCCP via the SCRC code */
- return scrc_rx_mtp_xfer_ind_xua(inst, xua);
+ rc = scrc_rx_mtp_xfer_ind_xua(inst, xua);
default:
LOGP(DLSCCP, LOGL_ERROR, "Unknown primitive %u:%u receivd\n",
oph->primitive, oph->operation);
- return -1;
+ rc = -1;
}
+ msgb_free(oph->msg);
+ return rc;
}
static LLIST_HEAD(sccp_instances);
--
To view, visit https://gerrit.osmocom.org/2242
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I708505d129da5824c69b31a13a9c93201929bada
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>