From 5cea18e5cbb1194b15df09f822345524380b94d2 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 3 Dec 2018 18:17:18 +0100 Subject: lms: Make sure LMS_Close is called when Device is torn down This change fixes lots of memory leaks inside libLimeSuite as announced by ASan after exiting the osmo-trx process (throgh CTRL+C for instance). This way also we make sure libLimeSuite can communicate with the HW and close whatever subsystems were enabled during LMS_Open time. Change-Id: I56ffb87079e34aa2d0322fd2ca6429742f9f7640 --- Transceiver52M/device/lms/LMSDevice.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Transceiver52M/device/lms/LMSDevice.cpp') diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp index 2ceca0d..144f75d 100644 --- a/Transceiver52M/device/lms/LMSDevice.cpp +++ b/Transceiver52M/device/lms/LMSDevice.cpp @@ -57,6 +57,15 @@ LMSDevice::LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t c m_last_tx_overruns.resize(chans, 0); } +LMSDevice::~LMSDevice() +{ + LOGC(DDEV, INFO) << "Closing LMS device"; + if (m_lms_dev) { + LMS_Close(m_lms_dev); + m_lms_dev = NULL; + } +} + static void lms_log_callback(int lvl, const char *msg) { /* map lime specific log levels */ @@ -204,6 +213,7 @@ int LMSDevice::open(const std::string &args, int ref, bool swap_channels) out_close: LOGC(DDEV, ALERT) << "Error in LMS open, closing: " << LMS_GetLastErrorMessage(); LMS_Close(m_lms_dev); + m_lms_dev = NULL; return -1; } -- cgit v1.2.3