From 5600316d343da3f2bafa8dee24ca72c6e94d2030 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 3 Dec 2024 12:18:47 +0100 Subject: [PATCH] UL ref sequences: prevent double-initialization The existing code prevents double initialization if e.g., both gNB&UE call these functions (like in a simulator). However, in the case of a double-initialization such as stopping and re-starting the L1, the memory will be freed, but not freed again. Basically, this works: generate() generate() # not initialized again but this leads to problems: generate() free() generate() # not initialized again, but should be! Reimplement the check based on the data to be initialized, such that an intermediate free() will be handled properly. --- openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c index 22fe1b0d13..baa2734f87 100644 --- a/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c +++ b/openair1/PHY/NR_REFSIG/ul_ref_seq_nr.c @@ -177,10 +177,9 @@ c16_t *gNB_dmrs_lowpaprtype1_sequence[U_GROUP_NUMBER][V_BASE_SEQUENCE_NUMBER][MA void generate_lowpapr_typ1_refsig_sequences(unsigned int scaling) { /* prevent multiple calls, relevant when both UE & gNB initialize this */ - static bool already_called = false; + bool already_called = gNB_dmrs_lowpaprtype1_sequence[0][0][0] != NULL; if (already_called) return; - already_called = true; unsigned int v = 0; // sequence hopping and group hopping are not supported yet for (unsigned int Msc_RS = 0; Msc_RS <= INDEX_SB_LESS_32; Msc_RS++) { @@ -200,9 +199,8 @@ c16_t *dmrs_lowpaprtype1_ul_ref_sig[U_GROUP_NUMBER][V_BASE_SEQUENCE_NUMBER][MAX_ void generate_ul_reference_signal_sequences(unsigned int scaling) { /* prevent multiple calls, relevant when both UE & gNB initialize this */ - static bool already_called = false; + bool already_called = rv_ul_ref_sig[0][0][0] != NULL; if (already_called) return; - already_called = true; unsigned int u,v,Msc_RS;