From c4570bc829d1b94f6d9f276603fa208b2cbdb3d2 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Fri, 12 Jul 2024 17:28:23 +0200 Subject: [PATCH] Avoid segfault in SRS modulation when ue-nb-ant-tx (fp) does not match UE capabilities * the mismatch between UE capabilities, passed to PHY by NFAPI PDU, and --ue-nb-ant-tx causes a segfault in SRS modulation * issue with indexing txdataF[p_index], which fails due to an out-of-bounds access since first dimension of txdataF is sized based on ue->frame_parms.nb_antennas_tx * N_ap used in SRS modulation is based on the number of antenna ports in the SRS configuration (srs_config_pdu->num_ant_ports) --- openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c index 4af545b931..02ad38cc0e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/srs_modulation_nr.c @@ -205,7 +205,9 @@ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu, uint16_t T_SRS = srs_config_pdu->t_srs; uint16_t T_offset = srs_config_pdu->t_offset; uint8_t R = 1<num_repetitions; - uint8_t N_ap = 1<num_ant_ports; // Number of antenna port for transmission + /* Number of antenna ports (M) can't be higher than number of physical antennas (N): M <= N */ + uint8_t num_ant_ports = 1 << srs_config_pdu->num_ant_ports; // Number of antenna port for transmission + int N_ap = num_ant_ports > frame_parms->nb_antennas_tx ? frame_parms->nb_antennas_tx : num_ant_ports; uint8_t N_symb_SRS = 1<num_symbols; // Number of consecutive OFDM symbols uint8_t l0 = frame_parms->symbols_per_slot - 1 - l_offset; // Starting symbol position in the time domain uint8_t n_SRS_cs_max = srs_max_number_cs[srs_config_pdu->comb_size];