diff --git a/src/app/OperationalDeviceProxy.cpp b/src/app/OperationalDeviceProxy.cpp index 29a1b37a775b72..f6f1296bb44799 100644 --- a/src/app/OperationalDeviceProxy.cpp +++ b/src/app/OperationalDeviceProxy.cpp @@ -302,6 +302,12 @@ CHIP_ERROR OperationalDeviceProxy::ShutdownSubscriptions() return app::InteractionModelEngine::GetInstance()->ShutdownSubscriptions(mFabricInfo->GetFabricIndex(), GetDeviceId()); } -OperationalDeviceProxy::~OperationalDeviceProxy() {} +OperationalDeviceProxy::~OperationalDeviceProxy() { + if (mCASEClient) + { + // Make sure we don't leak it. + mInitParams.clientPool->Release(mCASEClient); + } +} } // namespace chip diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index f9b1cc3c770ef5..7741684baba239 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -246,6 +246,19 @@ CHIP_ERROR DeviceController::Shutdown() mState = State::NotInitialized; + if (mFabricInfo != nullptr) { + // Shut down any ongoing CASE session activity we have. + // https://github.com/project-chip/connectedhomeip/issues/15808 tracks + // the weird use of compressed fabric id as a key here. + mCASESessionManager->ReleaseSessionForFabric(GetCompressedFabricId()); + + // TODO: The CASE session manager does not shut down existing CASE + // sessions. It just shuts down any ongoing CASE session establishment + // we're in the middle of as initiator. Maybe it should shut down + // existing sessions too? + mSystemState->SessionMgr()->ExpireAllPairingsForFabric(mFabricInfo->GetFabricIndex()); + } + mStorageDelegate = nullptr; if (mFabricInfo != nullptr)