aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs/gprs_sgsn.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-07-12 00:25:51 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-08-27 17:40:54 +0200
commit26c146547590c61b0fa4461c203cbe6194669d6e (patch)
tree298adc03dd46e0400bff93900355098e5e6818cf /src/gprs/gprs_sgsn.c
parentbf982e066df041f22ebd86b34608cc26b10523be (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. RelateD: OS#2361 Change-Id: I7dad4a4d52fe05f6b990359841b4408df5990e21
Diffstat (limited to 'src/gprs/gprs_sgsn.c')
-rw-r--r--src/gprs/gprs_sgsn.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index 11225ddb..93b133f3 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -129,6 +129,7 @@ static const struct rate_ctr_group_desc sgsn_ctrg_desc = {
void sgsn_rate_ctr_init() {
sgsn->rate_ctrs = rate_ctr_group_alloc(tall_bsc_ctx, &sgsn_ctrg_desc, 0);
+ OSMO_ASSERT(sgsn->rate_ctrs);
}
/* look-up an SGSN MM context based on Iu UE context (struct ue_conn_ctx)*/
@@ -229,6 +230,11 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
get_value_string(gprs_cipher_names, ctx->ciph_algo));
ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, tlli);
+ if (!ctx->ctrg) {
+ LOGMMCTXP(LOGL_ERROR, ctx, "Cannot allocate counter group\n");
+ talloc_free(ctx);
+ return NULL;
+ }
INIT_LLIST_HEAD(&ctx->pdp_list);
llist_add(&ctx->list, &sgsn_mm_ctxts);
@@ -253,6 +259,11 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx)
ctx->pmm_state = PMM_DETACHED;
ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, 0);
+ if (!ctx->ctrg) {
+ LOGMMCTXP(LOGL_ERROR, ctx, "Cannot allocate counter group\n");
+ talloc_free(ctx);
+ return NULL;
+ }
/* Need to get RAID from IU conn */
ctx->ra = ctx->iu.ue_ctx->ra_id;
@@ -380,6 +391,11 @@ struct sgsn_pdp_ctx *sgsn_pdp_ctx_alloc(struct sgsn_mm_ctx *mm,
pdp->mm = mm;
pdp->nsapi = nsapi;
pdp->ctrg = rate_ctr_group_alloc(pdp, &pdpctx_ctrg_desc, nsapi);
+ if (!pdp->ctrg) {
+ LOGPDPCTXP(LOGL_ERROR, pdp, "Error allocation counter group\n");
+ talloc_free(pdp);
+ return NULL;
+ }
llist_add(&pdp->list, &mm->pdp_list);
llist_add(&pdp->g_list, &sgsn_pdp_ctxts);