Skip to content

Commit

Permalink
[openthread] Fixed potential usage fault (#33434)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kkasperczyk-no authored May 14, 2024
1 parent d594086 commit 052f162
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,22 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const

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

if (mIsAttached)
if (delegate)
{
delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kConnected);
}
else
{
delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kNotConnected);
if (mIsAttached)
{
delegate->OnConnectionStatusChanged(app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kConnected);
}
else
{
delegate->OnConnectionStatusChanged(
app::Clusters::ThreadNetworkDiagnostics::ConnectionStatusEnum::kNotConnected);

GeneralFaults<kMaxNetworkFaults> current;
current.add(to_underlying(chip::app::Clusters::ThreadNetworkDiagnostics::NetworkFaultEnum::kLinkDown));
delegate->OnNetworkFaultChanged(mNetworkFaults, current);
mNetworkFaults = current;
GeneralFaults<kMaxNetworkFaults> current;
current.add(to_underlying(chip::app::Clusters::ThreadNetworkDiagnostics::NetworkFaultEnum::kLinkDown));
delegate->OnNetworkFaultChanged(mNetworkFaults, current);
mNetworkFaults = current;
}
}
}

Expand Down

0 comments on commit 052f162

Please sign in to comment.