Skip to content

Commit

Permalink
Fix crash on read Networks when not connected (#19588)
Browse files Browse the repository at this point in the history
* 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

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
cecille and restyled-commits authored Jun 16, 2022
1 parent 22888b0 commit 46cdb3f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,12 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N
std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);
std::unique_ptr<GError, GErrorDeleter> 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.
Expand Down

0 comments on commit 46cdb3f

Please sign in to comment.