From 805c968b594d83095e733678495971bdf7ea2cde Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 27 Nov 2025 15:16:46 +0100 Subject: [PATCH] Add a check for BWP start and size validity in configuration --- openair2/GNB_APP/gnb_config.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/openair2/GNB_APP/gnb_config.c b/openair2/GNB_APP/gnb_config.c index 081ce8607f..1f641fc6d9 100644 --- a/openair2/GNB_APP/gnb_config.c +++ b/openair2/GNB_APP/gnb_config.c @@ -1368,7 +1368,7 @@ void nfapi_stop_l1() } } -static void get_bwp_config(nr_mac_config_t *configuration) +static void get_bwp_config(nr_mac_config_t *configuration, const NR_ServingCellConfigCommon_t *scc) { char path[MAX_OPTNAME_SIZE * 2 + 8]; snprintf(path, sizeof(path), "%s.[%i]", GNB_CONFIG_STRING_GNB_LIST, 0); @@ -1377,10 +1377,13 @@ static void get_bwp_config(nr_mac_config_t *configuration) AssertFatal(configuration->num_additional_bwps >= 0 && configuration->num_additional_bwps <= 4, "Invalid number of additional BWPs %d\n", configuration->num_additional_bwps); + int bw = scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth; for (int i = 0; i < configuration->num_additional_bwps; i++) { configuration->bwp_config[i].id = i + 1; int bwp_start = *BWPParamList.paramarray[i][GNB_BWP_START_IDX].iptr; + AssertFatal(bwp_start >= 0 && bwp_start < bw, "Invalid BWP start value %d\n", bwp_start); int bwp_size = *BWPParamList.paramarray[i][GNB_BWP_SIZE_IDX].iptr; + AssertFatal(bwp_start + bwp_size <= bw, "BWP start %d and BWP size %d exceeds full BW %d\n", bwp_start, bwp_size, bw); configuration->bwp_config[i].location_and_bw = PRBalloc_to_locationandbandwidth(bwp_size, bwp_start); configuration->bwp_config[i].scs = *BWPParamList.paramarray[i][GNB_BWP_SCS_IDX].iptr; LOG_I(GNB_APP, @@ -1418,12 +1421,6 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg) config.pdsch_AntennaPorts.XP, config.pusch_AntennaPorts); - // BWP - get_bwp_config(&config); - AssertFatal(config.num_additional_bwps <= 4, "Impossible to configure more than 4 additional BWPs\n"); - config.first_active_bwp = *GNBParamList.paramarray[0][GNB_1ST_ACTIVE_BWP_IDX].iptr; - AssertFatal(config.first_active_bwp <= config.num_additional_bwps, "1st active BWP does not belog to the configured BWPs\n"); - // RU GET_PARAMS_LIST(RUParamList, RUParams, RUPARAMS_DESC, CONFIG_STRING_RU_LIST, NULL); int num_tx = 0; @@ -1524,7 +1521,11 @@ void RCconfig_nr_macrlc(configmodule_interface_t *cfg) config.num_agg_level_candidates[PDCCH_AGG_LEVEL16]); NR_ServingCellConfigCommon_t *scc = get_scc_config(cfg, config.minRXTXTIME, config.do_SRS); - //xer_fprint(stdout, &asn_DEF_NR_ServingCellConfigCommon, scc); + // BWP + get_bwp_config(&config, scc); + AssertFatal(config.num_additional_bwps <= 4, "Impossible to configure more than 4 additional BWPs\n"); + config.first_active_bwp = *GNBParamList.paramarray[0][GNB_1ST_ACTIVE_BWP_IDX].iptr; + AssertFatal(config.first_active_bwp <= config.num_additional_bwps, "1st active BWP does not belog to the configured BWPs\n"); if (MacRLC_ParamList.numelt > 0) { /* NR RLC config is needed by mac_top_init_gNB() */