From f3a778f98044e00a9b26126850ead9d2e7625041 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 24 Nov 2016 10:03:44 +1100 Subject: [PATCH] AP_InertialSensor: fixed freeing of fifo buffer --- libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp | 2 +- libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp index 126c036fc7..2827134cbc 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_MPU6000.cpp @@ -262,7 +262,7 @@ AP_InertialSensor_MPU6000::AP_InertialSensor_MPU6000(AP_InertialSensor &imu, AP_InertialSensor_MPU6000::~AP_InertialSensor_MPU6000() { if (_fifo_buffer != nullptr) { - delete[] _fifo_buffer; + hal.util->dma_free(_fifo_buffer, MPU_FIFO_BUFFER_LEN * MPU_SAMPLE_SIZE); } delete _auxiliary_bus; } diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp index e5065eed48..b02c2d39f9 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_MPU9250.cpp @@ -220,6 +220,9 @@ AP_InertialSensor_MPU9250::AP_InertialSensor_MPU9250(AP_InertialSensor &imu, AP_InertialSensor_MPU9250::~AP_InertialSensor_MPU9250() { + if (_fifo_buffer != nullptr) { + hal.util->dma_free(_fifo_buffer, MPU_FIFO_BUFFER_LEN * MPU_SAMPLE_SIZE); + } delete _auxiliary_bus; }