Commit 7b50e686 authored by Ken Rockot's avatar Ken Rockot Committed by Commit Bot

Revert "[CrOS MultiDevice] Fix crash in BleConnectionManagerImpl."

This reverts commit 17b07c4c.

Reason for revert: Breaking chromeos_unittests, see https://crbug.com/909883

Original change's description:
> [CrOS MultiDevice] Fix crash in BleConnectionManagerImpl.
> 
> When a SecureChannel disconnects due to authentication failures,
> BleConnectionManagerImpl invokes the relevant failure callback, which
> then causes ConnectionAttemptBase to cancel the connection attempt.
> 
> When the attempt is cancelled, the SecureChannel object is deleted via
> BleConnectionManagerImpl::ProcessPotentialLingeringChannel(), but
> BleConnectionManagerImpl::HandleSecureChannelDisconnection() assumed
> that the object was still valid and tried to to remove itself as an
> observer, causing a segfault.
> 
> The fix is to check whether the object has been deleted before
> attempting to call RemoveObserver().
> 
> Bug: 905904
> Change-Id: Ic593ef4047ff481e218c89028324eb0863131cdc
> Reviewed-on: https://chromium-review.googlesource.com/c/1352855
> Reviewed-by: Ryan Hansberry <hansberry@chromium.org>
> Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#611781}

TBR=khorimoto@chromium.org,hansberry@chromium.org

Change-Id: I575b604a98318f778cd1f7d93c31e14806da2e3f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 905904
Reviewed-on: https://chromium-review.googlesource.com/c/1354327Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#611879}
parent bc4ea7f7
......@@ -503,15 +503,6 @@ void BleConnectionManagerImpl::HandleSecureChannelDisconnection(
// connection's latency should be reset and started anew.
remote_device_id_to_timestamps_map_[remote_device_id]->Reset();
if (!DoesAuthenticatingChannelExist(remote_device_id)) {
PA_LOG(ERROR) << "BleConnectionManagerImpl::"
<< "HandleSecureChannelDisconnection(): Disconnected channel "
<< "not present in map. Remote device ID: "
<< cryptauth::RemoteDeviceRef::TruncateDeviceIdForLogs(
remote_device_id);
NOTREACHED();
}
for (const auto& details : GetDetailsForRemoteDevice(remote_device_id)) {
switch (details.connection_role()) {
// Initiator role devices are notified of authentication errors as well as
......@@ -534,19 +525,10 @@ void BleConnectionManagerImpl::HandleSecureChannelDisconnection(
}
}
// It is possible that the NotifyBle*Failure() calls above resulted in
// observers responding to the failure by canceling the connection attempt.
// If all attempts to |remote_device_id| were cancelled, the disconnected
// channel will have already been cleaned up via
// ProcessPotentialLingeringChannel().
auto it = remote_device_id_to_secure_channel_map_.find(remote_device_id);
if (it == remote_device_id_to_secure_channel_map_.end())
return;
// Stop observing the disconnected channel and remove it from the map.
SecureChannelWithRole& secure_channel_with_role = it->second;
secure_channel_with_role.first->RemoveObserver(this);
remote_device_id_to_secure_channel_map_.erase(it);
remote_device_id_to_secure_channel_map_[remote_device_id]
.first->RemoveObserver(this);
remote_device_id_to_secure_channel_map_.erase(remote_device_id);
// Since the previous connection failed, the connection attempts that were
// paused in SetAuthenticatingChannel() need to be started up again. Note
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment