diff options
author | Harald Welte <laforge@gnumonks.org> | 2009-06-27 03:09:08 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2009-06-27 03:09:53 +0200 |
commit | eab33356d0685fa93cc29a30c0bcd5ffbf1a543d (patch) | |
tree | f45c17aa5f005090cf1428d5a7db5d62dffb0b4e /openbsc/src | |
parent | a0368540ab965a0d05bab113a72f8a4a9ec8aa20 (diff) |
fix various RSL msgb memory leaks in error paths
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/abis_rsl.c | 14 | ||||
-rw-r--r-- | openbsc/src/e1_input.c | 1 |
2 files changed, 11 insertions, 4 deletions
diff --git a/openbsc/src/abis_rsl.c b/openbsc/src/abis_rsl.c index 397d793c7..c2ef9e5cf 100644 --- a/openbsc/src/abis_rsl.c +++ b/openbsc/src/abis_rsl.c @@ -360,13 +360,15 @@ int rsl_sacch_filling(struct gsm_bts_trx *trx, u_int8_t type, int rsl_chan_bs_power_ctrl(struct gsm_lchan *lchan, unsigned int fpc, int db) { struct abis_rsl_dchan_hdr *dh; - struct msgb *msg = rsl_msgb_alloc(); + struct msgb *msg; u_int8_t chan_nr = lchan2chan_nr(lchan); db = abs(db); if (db > 30) return -EINVAL; + msg = rsl_msgb_alloc(); + lchan->bs_power = db/2; if (fpc) lchan->bs_power |= 0x10; @@ -457,7 +459,7 @@ static int ms_pwr_dbm(enum gsm_band band, u_int8_t lvl) int rsl_chan_ms_power_ctrl(struct gsm_lchan *lchan, unsigned int fpc, int dbm) { struct abis_rsl_dchan_hdr *dh; - struct msgb *msg = rsl_msgb_alloc(); + struct msgb *msg; u_int8_t chan_nr = lchan2chan_nr(lchan); int ctl_lvl; @@ -465,6 +467,8 @@ int rsl_chan_ms_power_ctrl(struct gsm_lchan *lchan, unsigned int fpc, int dbm) if (ctl_lvl < 0) return ctl_lvl; + msg = rsl_msgb_alloc(); + lchan->ms_power = ctl_lvl; if (fpc) @@ -521,7 +525,7 @@ int rsl_chan_activate_lchan(struct gsm_lchan *lchan, u_int8_t act_type, u_int8_t ta, u_int8_t mode) { struct abis_rsl_dchan_hdr *dh; - struct msgb *msg = rsl_msgb_alloc(); + struct msgb *msg; u_int8_t chan_nr = lchan2chan_nr(lchan); u_int16_t arfcn = lchan->ts->trx->arfcn; @@ -564,6 +568,7 @@ int rsl_chan_activate_lchan(struct gsm_lchan *lchan, u_int8_t act_type, ci.chan_desc.oct3 = (lchan->ts->trx->bts->tsc << 5) | ((arfcn & 0x3ff) >> 8); ci.chan_desc.oct4 = arfcn & 0xff; + msg = rsl_msgb_alloc(); dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh)); init_dchan_hdr(dh, RSL_MT_CHAN_ACTIV); dh->chan_nr = chan_nr; @@ -591,7 +596,7 @@ int rsl_chan_activate_lchan(struct gsm_lchan *lchan, u_int8_t act_type, int rsl_chan_mode_modify_req(struct gsm_lchan *lchan) { struct abis_rsl_dchan_hdr *dh; - struct msgb *msg = rsl_msgb_alloc(); + struct msgb *msg; u_int8_t chan_nr = lchan2chan_nr(lchan); struct rsl_ie_chan_mode cm; @@ -622,6 +627,7 @@ int rsl_chan_mode_modify_req(struct gsm_lchan *lchan) return -1; } + msg = rsl_msgb_alloc(); dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh)); init_dchan_hdr(dh, RSL_MT_MODE_MODIFY_REQ); dh->chan_nr = chan_nr; diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c index 56bce019c..2d0c1340f 100644 --- a/openbsc/src/e1_input.c +++ b/openbsc/src/e1_input.c @@ -236,6 +236,7 @@ int abis_rsl_sendmsg(struct msgb *msg) if (!msg->trx || !msg->trx->rsl_link) { fprintf(stderr, "rsl_sendmsg: msg->trx == NULL\n"); + talloc_free(msg); return -EINVAL; } |