From eab33356d0685fa93cc29a30c0bcd5ffbf1a543d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 27 Jun 2009 03:09:08 +0200 Subject: fix various RSL msgb memory leaks in error paths --- openbsc/src/abis_rsl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'openbsc/src/abis_rsl.c') 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; -- cgit v1.2.3