[PATCH] osmo-bts[master]: TRX: prevent segfault upon phy init

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/.

Max gerrit-no-reply at lists.osmocom.org
Fri Nov 25 16:05:21 UTC 2016


Hello Neels Hofmeyr, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1276

to look at the new patch set (#2).

TRX: prevent segfault upon phy init

Previously if multiply phy instances were configured but not used
osmo-bts-trx would segfault. Terminate with clear error message instead
so user can correct configuration. Example configuration which caused
problem:
...
phy 0
 instance 0
 instance 1
...
 trx 0
  phy 0 instance 0

Note the 2nd instance of phy 0 which is not used in trx later on.

Change-Id: Id979506731ea92401458f1060e87aeb690901539
---
M src/common/scheduler.c
M src/osmo-bts-trx/l1_if.c
2 files changed, 13 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/76/1276/2

diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index db1f977..fd5c584 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -166,6 +166,9 @@
 	uint8_t tn;
 	unsigned int i;
 
+	if (!trx)
+		return -EINVAL;
+
 	l1t->trx = trx;
 
 	LOGP(DL1C, LOGL_NOTICE, "Init scheduler for trx=%u\n", l1t->trx->nr);
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index ea2088b..96e2622 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -71,19 +71,22 @@
 		return NULL;
 	l1h->phy_inst = pinst;
 
-	trx_sched_init(&l1h->l1s, pinst->trx);
+	rc = trx_sched_init(&l1h->l1s, pinst->trx);
+	if (rc < 0) {
+		LOGP(DL1C, LOGL_FATAL, "Cannot initialize scheduler for phy "
+		     "instance %d\n", pinst->num);
+		return NULL;
+	}
 
 	rc = trx_if_open(l1h);
 	if (rc < 0) {
-		LOGP(DL1C, LOGL_FATAL, "Cannot initialize scheduler\n");
-		goto err;
+		LOGP(DL1C, LOGL_FATAL, "Cannot open TRX interface for phy "
+		     "instance %d\n", pinst->num);
+		l1if_close(l1h);
+		return NULL;
 	}
 
 	return l1h;
-
-err:
-	l1if_close(l1h);
-	return NULL;
 }
 
 void l1if_close(struct trx_l1h *l1h)

-- 
To view, visit https://gerrit.osmocom.org/1276
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id979506731ea92401458f1060e87aeb690901539
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list