diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-07-12 00:46:36 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-07-12 00:47:10 +0200 |
commit | 9530a404ce50fce6762dc64c12bb014fcfd43918 (patch) | |
tree | b75c3b1b1b63c67c78caf86832ffc46f71a6c3cd /src | |
parent | 8c8027c3070ad154f3fff5a6a50be710d12707dd (diff) |
check for missing result of rate_ctr_group_alloc()
In case the counter group allocation fails, we must handle this
gracefully and fail the allocation of the parent object, too.
Change-Id: Id6d780c67b4af15aaa5c6f2b8b00f2a0b70a7385
Related: OS#2361
Diffstat (limited to 'src')
-rw-r--r-- | src/bts.cpp | 2 | ||||
-rw-r--r-- | src/tbf.cpp | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/bts.cpp b/src/bts.cpp index 5192646f..2d289d77 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -207,7 +207,9 @@ BTS::BTS() } m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, &bts_ctrg_desc, 0); + OSMO_ASSERT(m_ratectrs); m_statg = osmo_stat_item_group_alloc(tall_pcu_ctx, &bts_statg_desc, 0); + OSMO_ASSERT(m_statg); } BTS::~BTS() diff --git a/src/tbf.cpp b/src/tbf.cpp index 48e8289b..bbed29ce 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -760,6 +760,10 @@ static int setup_tbf(struct gprs_rlcmac_tbf *tbf, tbf->name(), tbf->trx->trx_no, tbf->ul_slots(), tbf->dl_slots()); tbf->m_ctrs = rate_ctr_group_alloc(tbf, &tbf_ctrg_desc, 0); + if (!tbf->m_ctrs) { + LOGP(DRLCMAC, LOGL_ERROR, "Couldn't allocate TBF counters\n"); + return -1; + } return 0; } @@ -844,6 +848,11 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_egprs_ctrg_desc, 0); tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_ul_gprs_ctrg_desc, 0); + if (!tbf->m_ul_egprs_ctrs || !tbf->m_ul_gprs_ctrs) { + LOGP(DRLCMAC, LOGL_ERROR, "Couldn't allocate TBF UL counters\n"); + talloc_free(tbf); + return NULL; + } llist_add(&tbf->list(), &bts->bts->ul_tbfs()); tbf->bts->tbf_ul_created(); @@ -930,8 +939,18 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, if (tbf->is_egprs_enabled()) { tbf->egprs_calc_window_size(); tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_egprs_ctrg_desc, 0); + if (!tbf->m_dl_egprs_ctrs) { + LOGP(DRLCMAC, LOGL_ERROR, "Couldn't allocate EGPRS DL counters\n"); + talloc_free(tbf); + return NULL; + } } else { tbf->m_dl_gprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_gprs_ctrg_desc, 0); + if (!tbf->m_dl_gprs_ctrs) { + LOGP(DRLCMAC, LOGL_ERROR, "Couldn't allocate GPRS DL counters\n"); + talloc_free(tbf); + return NULL; + } } llist_add(&tbf->list(), &bts->bts->dl_tbfs()); @@ -1439,6 +1458,11 @@ struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts, &tbf_ul_egprs_ctrg_desc, 0); ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ul_gprs_ctrg_desc, 0); + if (!ul_tbf->m_ctrs || !ul_tbf->m_ul_egprs_ctrs || !ul_tbf->m_ul_gprs_ctrs) { + LOGP(DRLCMAC, LOGL_ERROR, "Cound not allocate TBF UL rate counters\n"); + talloc_free(ul_tbf); + return NULL; + } return ul_tbf; } |