Skip to content

Commit

Permalink
Update src/controller/CHIPDeviceController.cpp
Browse files Browse the repository at this point in the history
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
joonhaengHeo and bzbarsky-apple authored Apr 15, 2024
1 parent ad53e1e commit 122bcb2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,17 @@ void DeviceCommissioner::CleanupCommissioning(DeviceProxy * proxy, NodeId nodeId
if (completionStatus.err == CHIP_NO_ERROR)
{
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);
// CommissioningStageComplete uses mDeviceBeingCommissioned, which can
// be commissionee if we are cleaning up before we've gone operational. Normally
// that would not happen in this non-error case, _except_ if we were told to skip sending
// CommissioningComplete: in that case we do not have an operational DeviceProxy, so
// we're using our CommissioneeDeviceProxy to do a successful cleanup.
//
// This means we have to call CommissioningStageComplete() before we destroy commissionee.
//
// This should be safe, because CommissioningStageComplete() does not call CleanupCommissioning
// when called in the cleanup stage (which is where we are), and StopPairing does not directly release
// mDeviceBeingCommissioned.
CommissioningStageComplete(CHIP_NO_ERROR);
if (commissionee != nullptr)
{
Expand Down

0 comments on commit 122bcb2

Please sign in to comment.