diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 15d59e696d1a3c..8e41081f76695e 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -307,10 +307,10 @@ CHIP_ERROR DeviceController::Shutdown() #if CONFIG_DEVICE_LAYER ReturnErrorOnFailure(DeviceLayer::PlatformMgr().Shutdown()); #else - mSystemLayer->Shutdown(); mInetLayer->Shutdown(); - chip::Platform::Delete(mSystemLayer); + mSystemLayer->Shutdown(); chip::Platform::Delete(mInetLayer); + chip::Platform::Delete(mSystemLayer); #endif // CONFIG_DEVICE_LAYER mSystemLayer = nullptr; diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 238ef7218fa4bd..e0308cdac3f154 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -229,8 +229,8 @@ void JNI_OnUnload(JavaVM * jvm, void * reserved) sBleLayer.Shutdown(); #endif - sSystemLayer.Shutdown(); sInetLayer.Shutdown(); + sSystemLayer.Shutdown(); sJVM = NULL; chip::Platform::MemoryShutdown(); diff --git a/src/include/platform/internal/GenericPlatformManagerImpl.cpp b/src/include/platform/internal/GenericPlatformManagerImpl.cpp index 469112018946e5..82990ccd771ee7 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl.cpp +++ b/src/include/platform/internal/GenericPlatformManagerImpl.cpp @@ -124,8 +124,6 @@ template CHIP_ERROR GenericPlatformManagerImpl::_Shutdown() { CHIP_ERROR err; - ChipLogError(DeviceLayer, "System Layer shutdown"); - err = SystemLayer.Shutdown(); ChipLogError(DeviceLayer, "Inet Layer shutdown"); err = InetLayer.Shutdown(); @@ -133,6 +131,10 @@ CHIP_ERROR GenericPlatformManagerImpl::_Shutdown() ChipLogError(DeviceLayer, "BLE layer shutdown"); err = BLEMgr().GetBleLayer()->Shutdown(); #endif + + ChipLogError(DeviceLayer, "System Layer shutdown"); + err = SystemLayer.Shutdown(); + return err; }