Skip to content

Commit 2db44eb

Browse files
[openthread] Fixed potential usage fault (project-chip#33434)
Pointer to the ThreadDiagnosticsDelegate is used without a null check. It leads to the usage fault, if ThreadNetworkDiagnostics cluster is disabled and pointer is set to nullptr.
1 parent 648d7bf commit 2db44eb

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.hpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -227,18 +227,22 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const
227227

228228
ThreadDiagnosticsDelegate * delegate = GetDiagnosticDataProvider().GetThreadDiagnosticsDelegate();
229229

230-
if (mIsAttached)
230+
if (delegate)
231231
{
232-
delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kConnected);
233-
}
234-
else
235-
{
236-
delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kNotConnected);
232+
if (mIsAttached)
233+
{
234+
delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kConnected);
235+
}
236+
else
237+
{
238+
delegate->OnConnectionStatusChanged(
239+
app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kNotConnected);
237240

238-
GeneralFaults<kMaxNetworkFaults> current;
239-
current.add(to_underlying(chip::app::Clusters::ThreadNetworkDiagnostics::NetworkFaultEnum::kLinkDown));
240-
delegate->OnNetworkFaultChanged(mNetworkFaults, current);
241-
mNetworkFaults = current;
241+
GeneralFaults<kMaxNetworkFaults> current;
242+
current.add(to_underlying(chip::app::Clusters::ThreadNetworkDiagnostics::NetworkFaultEnum::kLinkDown));
243+
delegate->OnNetworkFaultChanged(mNetworkFaults, current);
244+
mNetworkFaults = current;
245+
}
242246
}
243247
}
244248

0 commit comments

Comments
 (0)