diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c index d96a49310..f5b5a8f05 100644 --- a/lib/src/phy/common/phy_common.c +++ b/lib/src/phy/common/phy_common.c @@ -653,6 +653,7 @@ uint8_t srsran_band_get_band(uint32_t dl_earfcn) uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { ERROR("Invalid DL_EARFCN=%d", dl_earfcn); + return 0; } i--; while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) { @@ -666,6 +667,7 @@ double srsran_band_fd(uint32_t dl_earfcn) uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { ERROR("Invalid DL_EARFCN=%d", dl_earfcn); + return 0; } i--; while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) { @@ -679,6 +681,7 @@ double srsran_band_fu(uint32_t ul_earfcn) uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (ul_earfcn > lte_bands[i].ul_earfcn_offset) { ERROR("Invalid UL_EARFCN=%d", ul_earfcn); + return 0; } i--; while (i > 0 && (lte_bands[i].ul_earfcn_offset > ul_earfcn || lte_bands[i].ul_earfcn_offset == 0)) { @@ -692,6 +695,7 @@ uint32_t srsran_band_ul_earfcn(uint32_t dl_earfcn) uint32_t i = SRSRAN_NOF_LTE_BANDS - 1; if (dl_earfcn > lte_bands[i].dl_earfcn_offset) { ERROR("Invalid DL_EARFCN=%d", dl_earfcn); + return 0; } i--; while (i > 0 && lte_bands[i].dl_earfcn_offset > dl_earfcn) { diff --git a/srsenb/src/enb_cfg_parser.cc b/srsenb/src/enb_cfg_parser.cc index 8c379e5ed..d7666ef84 100644 --- a/srsenb/src/enb_cfg_parser.cc +++ b/srsenb/src/enb_cfg_parser.cc @@ -1104,6 +1104,10 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ phy_cell_cfg.dl_freq_hz = cfg.dl_freq_hz; } else { phy_cell_cfg.dl_freq_hz = 1e6 * srsran_band_fd(cfg.dl_earfcn); + if (phy_cell_cfg.dl_freq_hz == 0.0) { + ERROR("Couldn't derive DL frequency for EARFCN=%d", cfg.dl_earfcn); + return SRSRAN_ERROR; + } } if (cfg.ul_freq_hz > 0) { @@ -1113,6 +1117,10 @@ int set_derived_args(all_args_t* args_, rrc_cfg_t* rrc_cfg_, phy_cfg_t* phy_cfg_ cfg.ul_earfcn = srsran_band_ul_earfcn(cfg.dl_earfcn); } phy_cell_cfg.ul_freq_hz = 1e6 * srsran_band_fu(cfg.ul_earfcn); + if (phy_cell_cfg.ul_freq_hz == 0.0) { + ERROR("Couldn't derive UL frequency for EARFCN=%d", cfg.ul_earfcn); + return SRSRAN_ERROR; + } } for (auto scell_it = cfg.scell_list.begin(); scell_it != cfg.scell_list.end();) {