From b444d25462331714bf633a0f3715124786d0bf74 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 30 Aug 2022 15:30:59 -0400 Subject: [PATCH] Ignore DeviceCommissioner::OnDeviceConnectionFailureFn for unexpected devices. (#22247) Just like we ignore DeviceCommissioner::OnDeviceConnectedFn if the device id does not match mDeviceBeingCommissioned, we should ignore OnDeviceConnectionFailureFn. Fixes https://github.com/project-chip/connectedhomeip/issues/22244 --- src/controller/CHIPDeviceController.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 0452835651aec8..0bf9ee911359d9 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1653,6 +1653,13 @@ void DeviceCommissioner::OnDeviceConnectionFailureFn(void * context, const Scope error = CHIP_ERROR_INTERNAL; } + if (commissioner->mDeviceBeingCommissioned == nullptr || + commissioner->mDeviceBeingCommissioned->GetDeviceId() != peerId.GetNodeId()) + { + // Not the device we are trying to commission. + return; + } + if (commissioner->mCommissioningStage == CommissioningStage::kFindOperational && commissioner->mCommissioningDelegate != nullptr) {