Change in osmo-bts[master]: osmo-bts-trx: fix segfault on trx_phy_inst_open() failure

laforge gerrit-no-reply at lists.osmocom.org
Thu Apr 1 15:21:44 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/23399 )

Change subject: osmo-bts-trx: fix segfault on trx_phy_inst_open() failure
......................................................................

osmo-bts-trx: fix segfault on trx_phy_inst_open() failure

If for whatever reason it fails to initialize the TRXD or TRXC
interface, trx_phy_inst_open() would return an error.  This
would cause bts_model_phy_link_open() to call trx_if_close()
on each of the PHY links, including those that were never
opened.  This leads to a segfault in trx_if_close().

Make sure that in trx_if_init() we properly init 'struct trx_l1h',
so it's safe to call trx_if_close() at any time and in any state.

Change-Id: I1f128813528f505fede04799e84456f6271058d0
---
M src/osmo-bts-trx/trx_if.c
1 file changed, 6 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index c6701cb..2e97319 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -193,6 +193,12 @@
 {
 	l1h->trx_ctrl_timer.cb = trx_ctrl_timer_cb;
 	l1h->trx_ctrl_timer.data = l1h;
+
+	/* initialize ctrl queue */
+	INIT_LLIST_HEAD(&l1h->trx_ctrl_list);
+
+	l1h->trx_ofd_ctrl.fd = -1;
+	l1h->trx_ofd_data.fd = -1;
 }
 
 /*! Send a new TRX control command.
@@ -1215,9 +1221,6 @@
 
 	LOGPPHI(l1h->phy_inst, DTRX, LOGL_NOTICE, "Open transceiver\n");
 
-	/* initialize ctrl queue */
-	INIT_LLIST_HEAD(&l1h->trx_ctrl_list);
-
 	/* open sockets */
 	rc = trx_udp_open(l1h, &l1h->trx_ofd_ctrl,
 			  plink->u.osmotrx.local_ip,

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/23399
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I1f128813528f505fede04799e84456f6271058d0
Gerrit-Change-Number: 23399
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210401/2342f300/attachment.htm>


More information about the gerrit-log mailing list