From 8d87f0c4e2edb38c0bc0f5e447becf124c71ea20 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 27 Feb 2024 18:54:36 +0100 Subject: [PATCH] get_phy_stats(): full list is non-fatal Do not assert if the list of phy statistics is full; instead return NULL. In most places, this is handled appropriately (we do not store anything if we can't). In nr_decode_pucch0(), the return value of get_phy_stats() is used a little bit all over the function, and a constant if (uci_stats) uci_stats->variable++; would look ugly, so make uci_stats point to the stack if we cannot store in the phy_stats. --- openair1/PHY/INIT/nr_init.c | 5 ++++- openair1/PHY/NR_TRANSPORT/pucch_rx.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c index c864a0366a..1f918086b2 100644 --- a/openair1/PHY/INIT/nr_init.c +++ b/openair1/PHY/INIT/nr_init.c @@ -79,8 +79,11 @@ NR_gNB_PHY_STATS_t *get_phy_stats(PHY_VARS_gNB *gNB, uint16_t rnti) else if (!stats->active && first_free == -1) first_free = i; } + + if (first_free < 0) + return NULL; + // new stats - AssertFatal(first_free >= 0, "PHY statistics list is full\n"); stats = &gNB->phy_stats[first_free]; stats->active = true; stats->rnti = rnti; diff --git a/openair1/PHY/NR_TRANSPORT/pucch_rx.c b/openair1/PHY/NR_TRANSPORT/pucch_rx.c index 4ef42119bf..8a44e410f9 100644 --- a/openair1/PHY/NR_TRANSPORT/pucch_rx.c +++ b/openair1/PHY/NR_TRANSPORT/pucch_rx.c @@ -162,10 +162,15 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, pucch_pdu->bit_len_harq, pucch_pdu->sr_flag); + /* it might be that the stats list is full: In this case, we will simply + * write to some memory on the stack instead of the UE's UCI stats */ + NR_gNB_UCI_STATS_t stack_uci_stats = {0}; + NR_gNB_UCI_STATS_t *uci_stats = &stack_uci_stats; NR_gNB_PHY_STATS_t *phy_stats = get_phy_stats(gNB, pucch_pdu->rnti); - AssertFatal(phy_stats != NULL, "phy_stats shouldn't be NULL\n"); - phy_stats->frame = frame; - NR_gNB_UCI_STATS_t *uci_stats = &phy_stats->uci_stats; + if (phy_stats != NULL) { + phy_stats->frame = frame; + uci_stats = &phy_stats->uci_stats; + } int nr_sequences; const uint8_t *mcs;