Commit 752fa5fd authored by Cedric Roux's avatar Cedric Roux

nr rlc: hotfix: test allocation valid before use

and simplify a bit (DevAssert instead of goto/exit)
parent 220d851d
......@@ -32,13 +32,14 @@ nr_rlc_sdu_segment_t *nr_rlc_new_sdu(
{
/* allocate sdu header and data together */
nr_rlc_sdu_t *sdu = malloc(sizeof(nr_rlc_sdu_t) + size);
nr_rlc_sdu_segment_t *ret = calloc(1, sizeof(nr_rlc_sdu_segment_t));
DevAssert(sdu != NULL);
DevAssert(ret != NULL);
/* only memset the header */
memset(sdu, 0 , sizeof(*sdu));
nr_rlc_sdu_segment_t *ret = calloc(1, sizeof(nr_rlc_sdu_segment_t));
if (sdu == NULL || ret == NULL)
goto oom;
sdu->ref_count = 1;
sdu->sn = -1; /* set later */
sdu->upper_layer_id = upper_layer_id;
......@@ -54,10 +55,6 @@ nr_rlc_sdu_segment_t *nr_rlc_new_sdu(
ret->is_last = 1;
return ret;
oom:
LOG_E(RLC, "%s:%d:%s: out of memory\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
int nr_rlc_free_sdu_segment(nr_rlc_sdu_segment_t *sdu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment