Change in osmocom-bb[master]: trxcon/trx_if.c: check if trx_fsm allocation failed

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Thu Jan 17 12:48:45 UTC 2019


Vadim Yanitskiy has submitted this change and it was merged. ( https://gerrit.osmocom.org/12588 )

Change subject: trxcon/trx_if.c: check if trx_fsm allocation failed
......................................................................

trxcon/trx_if.c: check if trx_fsm allocation failed

Change-Id: I31c9f2a651182b258d0a4d4504365b778529715a
---
M src/host/trxcon/trx_if.c
1 file changed, 11 insertions(+), 4 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/host/trxcon/trx_if.c b/src/host/trxcon/trx_if.c
index 91b87a2..bff73cc 100644
--- a/src/host/trxcon/trx_if.c
+++ b/src/host/trxcon/trx_if.c
@@ -645,6 +645,16 @@
 		return -ENOMEM;
 	}
 
+	/* Allocate a new dedicated state machine */
+	trx_new->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx_new,
+		NULL, LOGL_DEBUG, "trx_interface");
+	if (trx_new->fsm == NULL) {
+		LOGP(DTRX, LOGL_ERROR, "Failed to allocate an instance "
+			"of FSM '%s'\n", trx_fsm.name);
+		talloc_free(trx_new);
+		return -ENOMEM;
+	}
+
 	/* Initialize CTRL queue */
 	INIT_LLIST_HEAD(&trx_new->trx_ctrl_list);
 
@@ -659,16 +669,13 @@
 	if (rc < 0)
 		goto error;
 
-	/* Allocate a new dedicated state machine */
-	trx_new->fsm = osmo_fsm_inst_alloc(&trx_fsm, trx_new,
-		NULL, LOGL_DEBUG, "trx_interface");
-
 	*trx = trx_new;
 
 	return 0;
 
 error:
 	LOGP(DTRX, LOGL_ERROR, "Couldn't establish UDP connection\n");
+	osmo_fsm_inst_free(trx_new->fsm);
 	talloc_free(trx_new);
 	return rc;
 }

-- 
To view, visit https://gerrit.osmocom.org/12588
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I31c9f2a651182b258d0a4d4504365b778529715a
Gerrit-Change-Number: 12588
Gerrit-PatchSet: 2
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190117/5a3b8df1/attachment.htm>


More information about the gerrit-log mailing list