aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-05-01 08:51:17 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-06-24 08:02:34 +0200
commit25346fe0d7a8b83acdee8332bec921dbb254f016 (patch)
tree119c2b9df41cab0def2565a4a76926ef0a2bf6c3
parenta7e75377767e86a3e5645c22239770b1939e9899 (diff)
sysmobts: Fix potential memory leaks in the prim callback handling
Make sure the l1msg is always freed in the callback. There were several error conditions were the msgb would not have been freed, in the case of the calib data and the system information the message was not freed even in normal condition. I will modify this code to __use a msgb. This allows to re-use the allocated msgb across read operations.
-rw-r--r--src/osmo-bts-sysmo/calib_file.c2
-rw-r--r--src/osmo-bts-sysmo/l1_if.c2
-rw-r--r--src/osmo-bts-sysmo/oml.c7
3 files changed, 8 insertions, 3 deletions
diff --git a/src/osmo-bts-sysmo/calib_file.c b/src/osmo-bts-sysmo/calib_file.c
index b886d61f..d8c9fd7d 100644
--- a/src/osmo-bts-sysmo/calib_file.c
+++ b/src/osmo-bts-sysmo/calib_file.c
@@ -350,6 +350,8 @@ static int calib_send_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
calib_files[st->last_file_idx].fname,
fl1h->calib_path ? "file" : "eeprom");
+ msgb_free(l1_msg);
+
st->last_file_idx++;
if (st->last_file_idx < ARRAY_SIZE(calib_files))
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c
index cc33a293..16f15239 100644
--- a/src/osmo-bts-sysmo/l1_if.c
+++ b/src/osmo-bts-sysmo/l1_if.c
@@ -1128,6 +1128,8 @@ static int info_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp)
"as software was compiled against old header files\n");
#endif
+ msgb_free(resp);
+
/* FIXME: clock related */
return 0;
}
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index 2145f2f3..36073920 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -206,6 +206,7 @@ static int opstart_compl(struct gsm_abis_mo *mo, struct msgb *l1_msg)
LOGP(DL1C, LOGL_ERROR, "Rx %s, status: %s\n",
get_value_string(femtobts_l1prim_names, l1p->id),
get_value_string(femtobts_l1status_names, status));
+ msgb_free(l1_msg);
return oml_mo_opstart_nack(mo, NM_NACK_CANT_PERFORM);
}
@@ -593,7 +594,7 @@ static int lchan_act_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
if (!lchan) {
LOGP(DL1C, LOGL_ERROR,
"Failed to find lchan for hLayer3=0x%x\n", ic->hLayer3);
- return -1;
+ goto err;
}
LOGP(DL1C, LOGL_INFO, "%s MPH-ACTIVATE.conf (%s ",
@@ -1011,7 +1012,7 @@ static int chmod_modif_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
if (!lchan) {
LOGP(DL1C, LOGL_ERROR,
"Failed to find lchan for hLayer3=0x%x\n", cc->hLayer3);
- return -1;
+ goto err;
}
LOGP(DL1C, LOGL_INFO, "%s MPH-CONFIG.conf (%s) ",
@@ -1222,7 +1223,7 @@ static int lchan_deact_compl_cb(struct gsm_bts_trx *trx, struct msgb *l1_msg)
if (!lchan) {
LOGP(DL1C, LOGL_ERROR,
"Failed to find lchan for hLayer3=0x%x\n", ic->hLayer3);
- return -1;
+ goto err;
}
LOGP(DL1C, LOGL_INFO, "%s MPH-DEACTIVATE.conf (%s ",