bmp388: fix double free in case the driver probing fails

'interface' is freed in BMP388's destructor.
This commit is contained in:
Beat Küng 2020-02-21 13:56:48 +01:00 committed by Daniel Agar
parent c5a0d9077b
commit 0c6d558c50
1 changed files with 7 additions and 2 deletions

View File

@ -103,10 +103,15 @@ static bool start_bus(bmp388_bus_option &bus)
BMP388 *dev = new BMP388(interface);
if (dev == nullptr || (dev->init() != PX4_OK)) {
if (dev == nullptr) {
PX4_ERR("alloc failed");
delete interface;
return false;
}
if (dev->init() != PX4_OK) {
PX4_ERR("driver start failed");
delete dev;
delete interface;
return false;
}