Skip to content

Commit 1534492

Browse files
kpschoedelpull[bot]
authored andcommitted
Fix CommissioningWindowManager DNS UDP leak (#11983)
#### Problem `chip::Server::Shutdown()` contains ``` chip::Dnssd::ServiceAdvertiser::Instance().Shutdown(); ⋮ mCommissioningWindowManager.Cleanup(); ``` but the latter restarts `Dnssd::ServiceAdvertiser`. Instance of #11880 _Possible use of destroyed pool objects_ #### Change overview Add `CommissioningWindowManager::Shutdown()` which does not restart DNS. #### Testing If `ObjectPool` checks that objects do not outlive it (originally part of PR #11698 but deferred due to current leaks), then `TestCommissionManager` fails without this change.
1 parent c12484e commit 1534492

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/app/server/CommissioningWindowManager.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
7171
}
7272
}
7373

74-
void CommissioningWindowManager::Cleanup()
74+
void CommissioningWindowManager::Shutdown()
7575
{
7676
StopAdvertisement();
7777

@@ -84,6 +84,11 @@ void CommissioningWindowManager::Cleanup()
8484

8585
memset(&mECMPASEVerifier, 0, sizeof(mECMPASEVerifier));
8686
memset(mECMSalt, 0, sizeof(mECMSalt));
87+
}
88+
89+
void CommissioningWindowManager::Cleanup()
90+
{
91+
Shutdown();
8792

8893
// reset all advertising
8994
app::DnssdServer::Instance().StartServer(Dnssd::CommissioningMode::kDisabled);

src/app/server/CommissioningWindowManager.h

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CommissioningWindowManager : public SessionEstablishmentDelegate
6565
void OnSessionEstablishmentStarted() override;
6666
void OnSessionEstablished() override;
6767

68+
void Shutdown();
6869
void Cleanup();
6970

7071
void OnPlatformEvent(const DeviceLayer::ChipDeviceEvent * event);

src/app/server/Server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void Server::Shutdown()
184184
mExchangeMgr.Shutdown();
185185
mSessions.Shutdown();
186186
mTransports.Close();
187-
mCommissioningWindowManager.Cleanup();
187+
mCommissioningWindowManager.Shutdown();
188188
chip::Platform::MemoryShutdown();
189189
}
190190

src/app/tests/TestCommissionManager.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ void CheckCommissioningWindowManagerEnhancedWindow(nlTestSuite * suite, void *)
138138
void TearDownTask(intptr_t context)
139139
{
140140
chip::Server::GetInstance().Shutdown();
141-
chip::DeviceLayer::PlatformMgr().Shutdown();
142141
}
143142

144143
const nlTest sTests[] = {
@@ -167,6 +166,8 @@ int TestCommissioningWindowManager()
167166
// TODO: The platform memory was intentionally left not deinitialized so that minimal mdns can destruct
168167
chip::DeviceLayer::PlatformMgr().ScheduleWork(TearDownTask, 0);
169168
sleep(kTestTaskWaitSeconds);
169+
chip::DeviceLayer::PlatformMgr().StopEventLoopTask();
170+
chip::DeviceLayer::PlatformMgr().Shutdown();
170171

171172
return (nlTestRunnerStats(&theSuite));
172173
}

0 commit comments

Comments
 (0)