From 6fdb69a898666a5d8f2befcd85f69326386a7a2f Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 25 Apr 2024 15:24:36 +0200 Subject: [PATCH] fix for possible infinite loop in UE PUCCH multiplexing --- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 24 +++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 5f0bc51e9a..fa845a21c5 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -1830,10 +1830,17 @@ void order_resources(PUCCH_sched_t *pucch, int num_res) } } -bool check_overlapping_resources(int curr_start, int curr_length, int next_start, int next_length) +bool check_overlapping_resources(PUCCH_sched_t *pucch, int j, int o) { // assuming overlapping means if two resources overlaps in time, // ie share a symbol in the slot regardless of PRB + NR_PUCCH_Resource_t *pucch_resource = pucch[j - o].pucch_resource; + int curr_start, curr_length; + get_pucch_start_symbol_length(pucch_resource, &curr_start, &curr_length); + pucch_resource = pucch[j + 1].pucch_resource; + int next_start, next_length; + get_pucch_start_symbol_length(pucch_resource, &next_start, &next_length); + if (curr_start == next_start) return true; if (curr_start + curr_length - 1 < next_start) @@ -2179,18 +2186,9 @@ void multiplex_pucch_resource(NR_UE_MAC_INST_t *mac, PUCCH_sched_t *pucch, int n int j = 0; int o = 0; while (j <= num_res - 1) { - if (j < num_res - 1) { - NR_PUCCH_Resource_t *pucch_resource = pucch[j - o].pucch_resource; - int curr_start, curr_length; - get_pucch_start_symbol_length(pucch_resource, &curr_start, &curr_length); - pucch_resource = pucch[j + 1].pucch_resource; - int next_start, next_length; - get_pucch_start_symbol_length(pucch_resource, &next_start, &next_length); - bool overlap = check_overlapping_resources(curr_start, curr_length, next_start, next_length); - if (overlap) { - o++; - j++; - } + if ((j < num_res - 1) && check_overlapping_resources(pucch, j, o)) { + o++; + j++; } else { if (o > 0) { merge_resources(&pucch[j - o], o + 1, pucch_Config);