From 6d3135ce503bbc55575a0004ef02c72902be7370 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 8 May 2019 14:00:37 +0200 Subject: deal with rate_ctr_group_alloc() returning NULL Change-Id: I47d6623b9eca704e3c2537cfb5799a4c0749a7bc Related: #3701 --- src/gb/gprs_bssgp.c | 4 ++++ src/gb/gprs_ns.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 550757f9..b695c284 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -128,6 +128,10 @@ struct bssgp_bvc_ctx *btsctx_alloc(uint16_t bvci, uint16_t nsei) ctx->nsei = nsei; /* FIXME: BVCI is not unique, only BVCI+NSEI ?!? */ ctx->ctrg = rate_ctr_group_alloc(ctx, &bssgp_ctrg_desc, bvci); + if (!ctx->ctrg) { + talloc_free(ctx); + return NULL; + } ctx->fc = talloc_zero(ctx, struct bssgp_flow_control); /* cofigure for 2Mbit, 30 packets in queue */ bssgp_fc_init(ctx->fc, 100000, 2*1024*1024/8, 30, &_bssgp_tx_dl_ud); diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index d72003ed..3679a5ba 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -333,6 +333,10 @@ struct gprs_nsvc *gprs_nsvc_create2(struct gprs_ns_inst *nsi, uint16_t nsvci, nsvc->nsi = nsi; osmo_timer_setup(&nsvc->timer, gprs_ns_timer_cb, nsvc); nsvc->ctrg = rate_ctr_group_alloc(nsvc, &nsvc_ctrg_desc, nsvci); + if (!nsvc->ctrg) { + talloc_free(nsvc); + return NULL; + } nsvc->statg = osmo_stat_item_group_alloc(nsvc, &nsvc_statg_desc, nsvci); nsvc->sig_weight = sig_weight; nsvc->data_weight = data_weight; -- cgit v1.2.3