From 78fcc11a300cb35b38864454de21238c22663bc8 Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Wed, 18 Sep 2019 18:14:15 +0200 Subject: [PATCH] Fixes minor unitialised/leaked memory --- lib/src/phy/fec/softbuffer.c | 4 ++++ srsue/hdr/phy/cc_worker.h | 2 +- srsue/hdr/phy/phy_common.h | 4 ++-- srsue/src/phy/cc_worker.cc | 1 - srsue/src/ue.cc | 5 +++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/src/phy/fec/softbuffer.c b/lib/src/phy/fec/softbuffer.c index 9d0ba07e4..9523eb7a2 100644 --- a/lib/src/phy/fec/softbuffer.c +++ b/lib/src/phy/fec/softbuffer.c @@ -138,11 +138,15 @@ void srslte_softbuffer_rx_reset_cb(srslte_softbuffer_rx_t *q, uint32_t nof_cb) { if (q->buffer_f[i]) { bzero(q->buffer_f[i], SOFTBUFFER_SIZE*sizeof(int16_t)); } + if (q->data[i]) { + bzero(q->data[i], sizeof(uint8_t) * 6144 / 8); + } } } if (q->cb_crc) { bzero(q->cb_crc, sizeof(bool) * q->max_cb); } + q->tb_crc = false; } diff --git a/srsue/hdr/phy/cc_worker.h b/srsue/hdr/phy/cc_worker.h index cd2570334..666f66a68 100644 --- a/srsue/hdr/phy/cc_worker.h +++ b/srsue/hdr/phy/cc_worker.h @@ -105,7 +105,7 @@ private: srslte_ul_sf_cfg_t sf_cfg_ul; uint32_t cc_idx; - bool pregen_enabled; + bool pregen_enabled = false; bool cell_initiated; cf_t* signal_buffer_rx[SRSLTE_MAX_PORTS]; cf_t* signal_buffer_tx[SRSLTE_MAX_PORTS]; diff --git a/srsue/hdr/phy/phy_common.h b/srsue/hdr/phy/phy_common.h index acf2d648d..6f606a81a 100644 --- a/srsue/hdr/phy/phy_common.h +++ b/srsue/hdr/phy/phy_common.h @@ -88,10 +88,10 @@ public: scell_cfg_t scell_cfg[SRSLTE_MAX_CARRIERS]; // Save last TBS for uplink (mcs >= 28) - srslte_ra_tb_t last_ul_tb[SRSLTE_MAX_HARQ_PROC][SRSLTE_MAX_CARRIERS]; + srslte_ra_tb_t last_ul_tb[SRSLTE_MAX_HARQ_PROC][SRSLTE_MAX_CARRIERS] = {}; // Save last TBS for DL (Format1C) - int last_dl_tbs[SRSLTE_MAX_HARQ_PROC][SRSLTE_MAX_CARRIERS][SRSLTE_MAX_CODEWORDS]; + int last_dl_tbs[SRSLTE_MAX_HARQ_PROC][SRSLTE_MAX_CARRIERS][SRSLTE_MAX_CODEWORDS] = {}; phy_common(uint32_t max_workers); diff --git a/srsue/src/phy/cc_worker.cc b/srsue/src/phy/cc_worker.cc index 539f886a1..e73014384 100644 --- a/srsue/src/phy/cc_worker.cc +++ b/srsue/src/phy/cc_worker.cc @@ -117,7 +117,6 @@ cc_worker::cc_worker(uint32_t cc_idx, uint32_t max_prb, srsue::phy_common* phy, ue_dl.pdsch.llr_is_8bit = true; ue_dl.pdsch.dl_sch.llr_is_8bit = true; } - pregen_enabled = false; } cc_worker::~cc_worker() diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 18b74fafc..7d3c5b9f9 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -44,6 +44,9 @@ ue::ue() : logger(nullptr) // load FFTW wisdom srslte_dft_load(); + // save FFTW wisdom when UE exits + atexit(srslte_dft_exit); + pool = byte_buffer_pool::get_instance(); } @@ -53,8 +56,6 @@ ue::~ue() stack.reset(); byte_buffer_pool::cleanup(); - // save FFTW wisdom - srslte_dft_exit(); } int ue::init(const all_args_t& args_, srslte::logger* logger_)