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
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;
 }