diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-05-19 15:52:07 +0200 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-05-19 16:53:06 +0200 |
commit | 6ad89f2f5808f33732904e5d9774307586cbf5a5 (patch) | |
tree | 4c40081ffd6787ddce6d284a35e5837881bc1015 /src/osmo-bts-trx/trx_vty.c | |
parent | dd9a6f16bc0427839b2619ddcf7d736f2cb5954d (diff) |
osmo-bts-{trx,virtual}: fix: pinst->trx may be NULL
We assume that it's legal to have dangling PHY instances that are
not associated with any TRX instances in the configuration file.
Obviously, such PHY instances have pinst->trx set to NULL.
The DSP based models seem to handle dangling PHY instances without
any problems, so let's ensure that we always check pinst->trx
against NULL in the osmo-bts-{trx,virtual} specific code.
Change-Id: Ib7d9cb7ae47fead723fa46454cd64bf6e88756bb
Fixes: CID#236092 "Dereference before null check"
Diffstat (limited to 'src/osmo-bts-trx/trx_vty.c')
-rw-r--r-- | src/osmo-bts-trx/trx_vty.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c index b85dcdc7..2b0913ff 100644 --- a/src/osmo-bts-trx/trx_vty.c +++ b/src/osmo-bts-trx/trx_vty.c @@ -99,17 +99,23 @@ static void show_phy_inst_single(struct vty *vty, struct phy_instance *pinst) struct trx_l1h *l1h = pinst->u.osmotrx.hdl; struct gsm_bts_trx *trx = pinst->trx; - vty_out(vty, "PHY Instance %s%s", - phy_instance_name(pinst), VTY_NEWLINE); + vty_out(vty, "PHY Instance '%s': bound to %s%s", + phy_instance_name(pinst), + gsm_trx_name(trx), + VTY_NEWLINE); + + if (trx != NULL) { + const int actual = get_p_actual_mdBm(trx, trx->power_params.p_total_tgt_mdBm); + const int max = get_p_max_out_mdBm(trx); + vty_out(vty, " tx-attenuation : %d dB%s", + (max - actual) / 1000, VTY_NEWLINE); + } if (l1h->config.rxgain_valid) vty_out(vty, " rx-gain : %d dB%s", l1h->config.rxgain, VTY_NEWLINE); else vty_out(vty, " rx-gain : undefined%s", VTY_NEWLINE); - vty_out(vty, " tx-attenuation : %d dB%s", - (get_p_max_out_mdBm(trx) - get_p_actual_mdBm(trx, trx->power_params.p_total_tgt_mdBm))/1000, - VTY_NEWLINE); if (l1h->config.maxdly_valid) vty_out(vty, " maxdly : %d%s", l1h->config.maxdly, VTY_NEWLINE); |