fixeria has submitted this change. (
https://gerrit.osmocom.org/c/osmo-bts/+/42510?usp=email )
Change subject: tx_power: get_pa_drive_level_mdBm(): assert on out-of-range
ARFCN
......................................................................
tx_power: get_pa_drive_level_mdBm(): assert on out-of-range ARFCN
The function previously returned `INT_MIN` as an error sentinel when
the ARFCN exceeded the calibration table size (1024 entries, covering
all valid GSM ARFCNs 0..1023). None of the callers checked for this
value, so it would silently propagate through power calculations and
eventually be passed to `bts_model_change_power()`.
An out-of-range ARFCN indicates a serious misconfiguration;
replace the range check and `return INT_MIN` with an `OSMO_ASSERT`.
Change-Id: I70c54652e0b07d399363276bc60946aa8b195725
---
M src/common/tx_power.c
1 file changed, 1 insertion(+), 3 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/common/tx_power.c b/src/common/tx_power.c
index 83cdb62..1e026dd 100644
--- a/src/common/tx_power.c
+++ b/src/common/tx_power.c
@@ -20,7 +20,6 @@
*/
#include <stdint.h>
-#include <limits.h>
#include <errno.h>
#include <osmocom/core/utils.h>
@@ -34,8 +33,7 @@
static int get_pa_drive_level_mdBm(const struct power_amp *pa,
int desired_p_out_mdBm, unsigned int arfcn)
{
- if (arfcn >= ARRAY_SIZE(pa->calib.delta_mdB))
- return INT_MIN;
+ OSMO_ASSERT(arfcn < ARRAY_SIZE(pa->calib.delta_mdB));
/* FIXME: temperature compensation */
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/42510?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I70c54652e0b07d399363276bc60946aa8b195725
Gerrit-Change-Number: 42510
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>