diff --git a/src/modules/ekf2/ekf2_main.cpp b/src/modules/ekf2/ekf2_main.cpp index f2ed912901..051b0f8b49 100644 --- a/src/modules/ekf2/ekf2_main.cpp +++ b/src/modules/ekf2/ekf2_main.cpp @@ -902,17 +902,17 @@ int ekf2_main(int argc, char *argv[]) ekf2::instance = new Ekf2(); + if (ekf2::instance == nullptr) { + PX4_WARN("alloc failed"); + return 1; + } + if (argc >= 3) { if (!strcmp(argv[2], "--replay")) { ekf2::instance->set_replay_mode(true); } } - if (ekf2::instance == nullptr) { - PX4_WARN("alloc failed"); - return 1; - } - if (OK != ekf2::instance->start()) { delete ekf2::instance; ekf2::instance = nullptr;