Skip to content

Commit

Permalink
Ignore the network interface update event if wifi name not init (#19439)
Browse files Browse the repository at this point in the history
The WiFi name is configured when WiFi init successfuly.
Sometime, the WiFi interface is not up in some Linux platform and instead
the platform use ethernet like eth0.
In this condition, eth0 will have the IP update event and this update listerner
will be called.
On this condition, the GetWiFiIfName() will report a nullptr and cause a Segmentation fault.

This patch will ignore the event and prevent the Segmentation fault.

Signed-off-by: Haoran Wang <[email protected]>
  • Loading branch information
TE-N-ElvenWang authored and pull[bot] committed Oct 31, 2023
1 parent 505fcb7 commit 9b1cdc9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ void PlatformManagerImpl::WiFIIPChangeListener()
continue;
}

if (ConnectivityManagerImpl::GetWiFiIfName() == nullptr)
{
ChipLogDetail(DeviceLayer, "No wifi interface name. Ignoring IP update event.");
continue;
}

if (strcmp(name, ConnectivityManagerImpl::GetWiFiIfName()) != 0)
{
continue;
Expand Down

0 comments on commit 9b1cdc9

Please sign in to comment.