From f007c8f55c26a7b6cb7bae5b25a444f30f772e4c Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Tue, 14 Jun 2022 16:17:27 -0400 Subject: [PATCH 1/2] Fix crash on read Networks when not connected This happens when running the example apps on linux with the wifi feature enabled (--wifi) because the device is actually connected via ethernet and wifi is not connected. This could happen in a prod device if > 1 network type was supported. Fixes #19585 --- src/platform/Linux/ConnectivityManagerImpl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index e2044e11c8712c..436d58a168a88b 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1346,6 +1346,11 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N std::lock_guard lock(mWpaSupplicantMutex); std::unique_ptr err; + if (mWpaSupplicant.iface == nullptr) { + ChipLogDetail(DeviceLayer, "Wifi network not currently connected"); + return CHIP_ERROR_INCORRECT_STATE; + } + const gchar * networkPath = wpa_fi_w1_wpa_supplicant1_interface_get_current_network(mWpaSupplicant.iface); // wpa_supplicant DBus API: if network path of current network is "/", means no networks is currently selected. From 7fbc590ba8fc53bdf9fc66b104b47b5cbf5cc07d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 14 Jun 2022 20:23:06 +0000 Subject: [PATCH 2/2] Restyled by clang-format --- src/platform/Linux/ConnectivityManagerImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index 436d58a168a88b..91186fef69ecf0 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1346,7 +1346,8 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N std::lock_guard lock(mWpaSupplicantMutex); std::unique_ptr err; - if (mWpaSupplicant.iface == nullptr) { + if (mWpaSupplicant.iface == nullptr) + { ChipLogDetail(DeviceLayer, "Wifi network not currently connected"); return CHIP_ERROR_INCORRECT_STATE; }