Skip to content

Commit 80f0f2b

Browse files
Fix Hardfault seen during commissioning DUT with second commissioner. (#41770)
* Add debug logs and fix * remove debug logs * PR comments * Restyled by whitespace * Restyled by clang-format * review comments * changes as per new analysis --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 4940afb commit 80f0f2b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/inet/UDPEndPoint.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,15 @@ CHIP_ERROR UDPEndPoint::SendMsg(const IPPacketInfo * pktInfo, System::PacketBuff
124124
void UDPEndPoint::Free()
125125
{
126126
Close();
127-
Delete();
127+
128+
// CloseImpl() may have called Ref() to keep endpoint alive for pending operations
129+
// (when mDelayReleaseCount != 0). Only delete if ref count is still 0.
130+
// If ref count > 0, the deferred Unref() scheduled by CloseImpl() will eventually
131+
// call Free() again when all pending operations complete.
132+
if (GetReferenceCount() == 0)
133+
{
134+
Delete();
135+
}
128136
}
129137

130138
void UDPEndPoint::Close()

0 commit comments

Comments
 (0)