[linux] Fix seg fault error if we do network provisioning twice. #4770
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The linux device crashed if we do network provisioning twice:
chip::DeviceLayer::ConnectivityMgrImpl().StartWiFiManagement();
(wait)
chip::DeviceLayer::ConnectivityManagerImpl::ProvisionWiFiNetwork(ssid, passwd);
(wait)
chip::DeviceLayer::ConnectivityManagerImpl::ProvisionWiFiNetwork(ssid, passwd);
According to the backtrace, seems we have some kind of double free issue:
#0 0x0000fffff7a3000c in g_type_check_instance_is_fundamentally_a () at /lib/aarch64-linux-gnu/libgobject-2.0.so.0
#1 0x0000fffff7a139b8 in g_object_unref () at /lib/aarch64-linux-gnu/libgobject-2.0.so.0
#2 0x0000aaaaaaae46a4 in chip::DeviceLayer::ConnectivityManagerImpl::ProvisionWiFiNetwork(char const*, char const*)
(this=0xaaaaaab919b8 chip::DeviceLayer::ConnectivityManagerImpl::sInstance, ssid=0xffffffffe7d0 "Nest-T", key=0xffffffffe7f8 "Nesttesting")
at ../third_party/connectedhomeip/src/platform/Linux/ConnectivityManagerImpl.cpp:849
Summary of Changes
Clean up current network if exists before provisioning
Fixes #4269