diff options
author | Max <msuraev@sysmocom.de> | 2023-02-19 18:56:36 +0300 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2023-02-19 18:56:56 +0300 |
commit | 495cf39cb9e6bb54a7a5fd1195988f4a03f3171a (patch) | |
tree | 80f5151b577a0cd19bb85e570bf9ff2499bfd03d | |
parent | 2f6e1059561109be2f5646610aa04a80be5ce0d3 (diff) |
bts-virtual: fix segfault
Premature activation of virtual scheduler in bts_model_phy_link_open()
leads to segfault in vbts_sched_start(). Fix this by moving scheduler
activation to bts_model_oml_estab()
Change-Id: I116c2548dd4d05df90c16e81fa2e85ed6027a2e1
-rw-r--r-- | src/osmo-bts-virtual/l1_if.c | 24 | ||||
-rw-r--r-- | src/osmo-bts-virtual/scheduler_virtbts.c | 3 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c index bba274d1..da25554b 100644 --- a/src/osmo-bts-virtual/l1_if.c +++ b/src/osmo-bts-virtual/l1_if.c @@ -187,6 +187,19 @@ nomessage: /* called by common part once OML link is established */ int bts_model_oml_estab(struct gsm_bts *bts) { + struct phy_instance *pinst = trx_phy_instance(bts->c0); + + if (vbts_sched_start(pinst->trx->bts) < 0) + return -ENOLINK; + + /* Only start the scheduler for the transceiver on C0. + * If we have multiple transceivers, CCCH is always on C0 + * and has to be auto active */ + pinst->trx->ts[0].lchan[CCCH_LCHAN].rel_act_kind = LCHAN_REL_ACT_OML; + + /* Other TRX are activated via OML by a PRIM_INFO_MODIFY / PRIM_INFO_ACTIVATE */ + lchan_set_state(&pinst->trx->ts[0].lchan[CCCH_LCHAN], LCHAN_S_ACTIVE); + return 0; } @@ -217,17 +230,6 @@ int bts_model_phy_link_open(struct phy_link *plink) if (pinst->trx == NULL) continue; trx_sched_init(pinst->trx); - /* Only start the scheduler for the transceiver on C0. - * If we have multiple transceivers, CCCH is always on C0 - * and has to be auto active */ - /* Other TRX are activated via OML by a PRIM_INFO_MODIFY - * / PRIM_INFO_ACTIVATE */ - if (pinst->trx == pinst->trx->bts->c0) { - vbts_sched_start(pinst->trx->bts); - /* FIXME: This is probably the wrong location to set the CCCH to active... the OML link def. needs to be reworked and fixed. */ - pinst->trx->ts[0].lchan[CCCH_LCHAN].rel_act_kind = LCHAN_REL_ACT_OML; - lchan_set_state(&pinst->trx->ts[0].lchan[CCCH_LCHAN], LCHAN_S_ACTIVE); - } } /* this will automatically update the MO state of all associated TRX objects */ diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c index d20cc397..72f03b4d 100644 --- a/src/osmo-bts-virtual/scheduler_virtbts.c +++ b/src/osmo-bts-virtual/scheduler_virtbts.c @@ -541,6 +541,9 @@ int vbts_sched_start(struct gsm_bts *bts) struct bts_virt_priv *bts_virt = (struct bts_virt_priv *)bts->model_priv; LOGP(DL1P, LOGL_NOTICE, "starting VBTS scheduler\n"); + if (!bts_virt) + return -EINVAL; + memset(&bts_virt->fn_timer, 0, sizeof(bts_virt->fn_timer)); bts_virt->fn_timer.cb = vbts_fn_timer_cb; bts_virt->fn_timer.data = bts; |