From 6c5e0d68ea3bc582d6b3b4d21376c74dd044ac08 Mon Sep 17 00:00:00 2001 From: Haoran Wang Date: Fri, 10 Jun 2022 13:26:27 +0000 Subject: [PATCH] Ignore the network interface update event if wifi name not init 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;