From 9b1cdc9324faa61a76088c4bf29f562e39b961db Mon Sep 17 00:00:00 2001 From: ElvenWang Date: Thu, 16 Jun 2022 08:26:25 +0800 Subject: [PATCH] Ignore the network interface update event if wifi name not init (#19439) 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 --- src/platform/Linux/PlatformManagerImpl.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index a4b8c432759487..791512ccbc4872 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -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;