osmo-pcu[master]: check for missing result of rate_ctr_group_alloc()

2017-07-13 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3183
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id6d780c67b4af15aaa5c6f2b8b00f2a0b70a7385
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: check for missing result of rate_ctr_group_alloc()

2017-07-13 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: check for missing result of rate_ctr_group_alloc()
..


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
---
M src/bts.cpp
M src/tbf.cpp
2 files changed, 26 insertions(+), 0 deletions(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.cpp b/src/bts.cpp
index 5192646..2d289d7 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -207,7 +207,9 @@
}
 
m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, _ctrg_desc, 0);
+   OSMO_ASSERT(m_ratectrs);
m_statg = osmo_stat_item_group_alloc(tall_pcu_ctx, _statg_desc, 0);
+   OSMO_ASSERT(m_statg);
 }
 
 BTS::~BTS()
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 48e8289..bbed29c 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -760,6 +760,10 @@
tbf->name(), tbf->trx->trx_no, tbf->ul_slots(), 
tbf->dl_slots());
 
tbf->m_ctrs = rate_ctr_group_alloc(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 @@
 
tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, 
_ul_egprs_ctrg_desc, 0);
tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(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(>list(), >bts->ul_tbfs());
tbf->bts->tbf_ul_created();
@@ -930,8 +939,18 @@
if (tbf->is_egprs_enabled()) {
tbf->egprs_calc_window_size();
tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(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, 
_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(>list(), >bts->dl_tbfs());
@@ -1439,6 +1458,11 @@
_ul_egprs_ctrg_desc, 0);
ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_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;
 }

-- 
To view, visit https://gerrit.osmocom.org/3183
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id6d780c67b4af15aaa5c6f2b8b00f2a0b70a7385
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 


osmo-pcu[master]: check for missing result of rate_ctr_group_alloc()

2017-07-11 Thread Vadim Yanitskiy

Patch Set 1: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/3183
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id6d780c67b4af15aaa5c6f2b8b00f2a0b70a7385
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: No


[PATCH] osmo-pcu[master]: check for missing result of rate_ctr_group_alloc()

2017-07-11 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3183

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
---
M src/bts.cpp
M src/tbf.cpp
2 files changed, 26 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/83/3183/1

diff --git a/src/bts.cpp b/src/bts.cpp
index 5192646..2d289d7 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -207,7 +207,9 @@
}
 
m_ratectrs = rate_ctr_group_alloc(tall_pcu_ctx, _ctrg_desc, 0);
+   OSMO_ASSERT(m_ratectrs);
m_statg = osmo_stat_item_group_alloc(tall_pcu_ctx, _statg_desc, 0);
+   OSMO_ASSERT(m_statg);
 }
 
 BTS::~BTS()
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 48e8289..bbed29c 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -760,6 +760,10 @@
tbf->name(), tbf->trx->trx_no, tbf->ul_slots(), 
tbf->dl_slots());
 
tbf->m_ctrs = rate_ctr_group_alloc(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 @@
 
tbf->m_ul_egprs_ctrs = rate_ctr_group_alloc(tbf, 
_ul_egprs_ctrg_desc, 0);
tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(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(>list(), >bts->ul_tbfs());
tbf->bts->tbf_ul_created();
@@ -930,8 +939,18 @@
if (tbf->is_egprs_enabled()) {
tbf->egprs_calc_window_size();
tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(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, 
_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(>list(), >bts->dl_tbfs());
@@ -1439,6 +1458,11 @@
_ul_egprs_ctrg_desc, 0);
ul_tbf->m_ul_gprs_ctrs = rate_ctr_group_alloc(ul_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;
 }

-- 
To view, visit https://gerrit.osmocom.org/3183
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6d780c67b4af15aaa5c6f2b8b00f2a0b70a7385
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte