From 44beab9c3b318c5bf5d3cde9f14bf3f6d7334d6c Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 18 Feb 2016 01:26:59 +0100 Subject: hnbgw: hnb_context_alloc(): fix missing free, missing return, wrong error return type Also move INIT_LLIST_HEAD further up for good measure (cosmetic). --- src/hnbgw.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hnbgw.c b/src/hnbgw.c index 2f2ab8c..798789c 100644 --- a/src/hnbgw.c +++ b/src/hnbgw.c @@ -231,17 +231,18 @@ struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_ ctx = talloc_zero(tall_hnb_ctx, struct hnb_context); if (!ctx) return NULL; + INIT_LLIST_HEAD(&ctx->map_list); ctx->gw = gw; ctx->conn = osmo_stream_srv_create(tall_hnb_ctx, link, new_fd, hnb_read_cb, hnb_close_cb, ctx); if (!ctx->conn) { LOGP(DMAIN, LOGL_INFO, "error while creating connection\n"); - return -1; + talloc_free(ctx); + return NULL; } - INIT_LLIST_HEAD(&ctx->map_list); - llist_add_tail(&ctx->list, &gw->hnb_list); + return ctx; } void hnb_context_release(struct hnb_context *ctx) -- cgit v1.2.3