aboutsummaryrefslogtreecommitdiffstats
path: root/src/libmsc/a_iface.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-09-07 11:39:58 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2017-09-11 10:14:00 +0200
commit4502f5ff5854157637de526bd64dc317df434be4 (patch)
treea80aa93f8053308141aefdb5232b9fb8230f1c9d /src/libmsc/a_iface.c
parentb305a004f7aa3e28f7ea52b36868826400fad483 (diff)
a_iface: fix memory leaks
Fix multiple memory leaske in A/BSSMAP code Change-Id: I90703c96e6a266a1cfa60b184139375aeb9ae32d
Diffstat (limited to 'src/libmsc/a_iface.c')
-rw-r--r--src/libmsc/a_iface.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 3d2013e62..8db6173e3 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -127,7 +127,7 @@ static struct a_reset_ctx *get_reset_ctx_by_sccp_addr(const struct osmo_sccp_add
return NULL;
}
-/* Send DTAP message via A-interface */
+/* Send DTAP message via A-interface, take ownership of msg */
int a_iface_tx_dtap(struct msgb *msg)
{
struct gsm_subscriber_connection *conn;
@@ -144,6 +144,11 @@ int a_iface_tx_dtap(struct msgb *msg)
msg->l3h = msg->data;
msg_resp = gsm0808_create_dtap(msg, link_id);
+
+ /* gsm0808_create_dtap() has copied the data to msg_resp,
+ * so msg has served its purpose now */
+ msgb_free(msg);
+
if (!msg_resp) {
LOGP(DMSC, LOGL_ERROR, "Unable to generate BSSMAP DTAP message!\n");
return -EINVAL;
@@ -151,6 +156,7 @@ int a_iface_tx_dtap(struct msgb *msg)
LOGP(DMSC, LOGL_DEBUG, "Massage will be sent as BSSMAP DTAP message!\n");
LOGP(DMSC, LOGL_DEBUG, "N-DATA.req(%u, %s)\n", conn->a.conn_id, osmo_hexdump(msg_resp->data, msg_resp->len));
+ /* osmo_sccp_tx_data_msg() takes ownership of msg_resp */
return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg_resp);
}