Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/12086 )

Change subject: lms: Make sure LMS_Close is called when Device is torn down
......................................................................

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
---
M Transceiver52M/device/lms/LMSDevice.cpp
M Transceiver52M/device/lms/LMSDevice.h
2 files changed, 11 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
        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 @@
 out_close:
        LOGC(DDEV, ALERT) << "Error in LMS open, closing: " << 
LMS_GetLastErrorMessage();
        LMS_Close(m_lms_dev);
+       m_lms_dev = NULL;
        return -1;
 }

diff --git a/Transceiver52M/device/lms/LMSDevice.h 
b/Transceiver52M/device/lms/LMSDevice.h
index 6635c13..d1a8813 100644
--- a/Transceiver52M/device/lms/LMSDevice.h
+++ b/Transceiver52M/device/lms/LMSDevice.h
@@ -74,6 +74,7 @@
        LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t 
chans, double lo_offset,
                  const std::vector<std::string>& tx_paths,
                  const std::vector<std::string>& rx_paths);
+       ~LMSDevice();

        /** Instantiate the LMS */
        int open(const std::string &args, int ref, bool swap_channels);

--
To view, visit https://gerrit.osmocom.org/12086
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I56ffb87079e34aa2d0322fd2ca6429742f9f7640
Gerrit-Change-Number: 12086
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <[email protected]>

Reply via email to