From 8411a428db04995a4bce45cae9eb79218858dc5d Mon Sep 17 00:00:00 2001 From: francescomani Date: Fri, 3 Oct 2025 09:20:22 +0200 Subject: [PATCH] prevent faulty behavior of nr_compute_tbs when null input is not producing TBS = 0 --- openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c | 5 +++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c index 96819378f0..1643d4e732 100644 --- a/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c +++ b/openair2/LAYER2/NR_MAC_COMMON/nr_compute_tbs_common.c @@ -59,6 +59,11 @@ uint32_t nr_compute_tbs(uint16_t Qm, tb_scaling, Nl); + if (Qm == 0 || R == 0 || nb_rb == 0 || Nl == 0) { + LOG_E(NR_MAC, "Error in compute TBS with a NULL input, returning NULL TBS\n"); + return 0; + } + const int nb_subcarrier_per_rb = 12; const uint32_t nbp_re = nb_subcarrier_per_rb * nb_symb_sch - nb_dmrs_prb - nb_rb_oh; const uint32_t nb_re = min(156, nbp_re) * nb_rb; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 21a032fde6..63be110ab7 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -673,8 +673,7 @@ bool nr_find_nb_rb(uint16_t Qm, uint16_t *nb_rb) { // for transform precoding only RB = 2^a_2 * 3^a_3 * 5^a_5 is allowed with a non-negative - while(transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled && - !multiple_2_3_5(nb_rb_max)) + while (transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled && !multiple_2_3_5(nb_rb_max)) nb_rb_max--; /* is the maximum (not even) enough? */