Skip to content

Commit

Permalink
Fix DisarmDone commissionee misssing null check (#22146)
Browse files Browse the repository at this point in the history
* Fix DisarmDone commissionee misssing null check

Problem: Obviously invoke commitee pointer is before the null check.
In low probability cases, commissioning failure before WiFiNetworkSetup and removing the device connection in the App will cause crash.

* Make sure nodeId has a value.
  • Loading branch information
panliming-tuya authored Aug 29, 2022
1 parent 55f9049 commit 16edce7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1520,12 +1520,13 @@ void DeviceCommissioner::DisarmDone()
// to do here.
VerifyOrReturn(mDeviceBeingCommissioned != nullptr);

NodeId nodeId = mDeviceBeingCommissioned->GetDeviceId();
// At this point, we also want to close off the pase session so we need to re-establish
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(mDeviceBeingCommissioned->GetDeviceId());
CommissioneeDeviceProxy * commissionee = FindCommissioneeDevice(nodeId);

// Signal completion - this will reset mDeviceBeingCommissioned.
CommissioningStageComplete(CHIP_NO_ERROR);
SendCommissioningCompleteCallbacks(commissionee->GetDeviceId(), commissioningCompletionStatus);
SendCommissioningCompleteCallbacks(nodeId, commissioningCompletionStatus);

// If we've disarmed the failsafe, it's because we're starting again, so kill the pase connection.
if (commissionee != nullptr)
Expand Down

0 comments on commit 16edce7

Please sign in to comment.