diff options
author | Ćukasz Rymanowski <lukasz.rymanowski@codecoup.pl> | 2021-05-26 09:02:38 +0000 |
---|---|---|
committer | Jakub Pawlowski <jpawlowski@google.com> | 2021-07-06 13:02:08 +0200 |
commit | 3dc8ae94b4be512527e3b287a63642844f38d840 (patch) | |
tree | 3b622364283fbb43817524135d83c1a632f40605 | |
parent | b33ab19823a97cc1d0f428968219e5ea108a9f78 (diff) | |
download | bt-3dc8ae94b4be512527e3b287a63642844f38d840.tar.gz |
eatt: Fix crash on double disconnect
Bug: 159786353
Tag: #feature
Test: atest --host net_test_eatt
Sponsor: jpawlowski@
Bug: 191313013
Merged-In: Ie4872f1c51445df59f2f68b127454d5f4d4e9ad0
Change-Id: Ie4872f1c51445df59f2f68b127454d5f4d4e9ad0
-rw-r--r-- | stack/eatt/eatt_impl.h | 11 | ||||
-rw-r--r-- | stack/test/eatt/eatt_test.cc | 8 |
2 files changed, 18 insertions, 1 deletions
diff --git a/stack/eatt/eatt_impl.h b/stack/eatt/eatt_impl.h index 2809c2b3a..59e7b786b 100644 --- a/stack/eatt/eatt_impl.h +++ b/stack/eatt/eatt_impl.h @@ -582,7 +582,16 @@ struct eatt_impl { LOG(INFO) << __func__ << " " << bd_addr; eatt_device* eatt_dev = find_device_by_address(bd_addr); - if (!eatt_dev) return; + if (!eatt_dev) { + LOG(WARNING) << __func__ << " no eatt device found"; + return; + } + + if (!eatt_dev->eatt_tcb_) { + LOG_ASSERT(eatt_dev->eatt_channels.size() == 0); + LOG(WARNING) << __func__ << " no eatt channels found"; + return; + } auto iter = eatt_dev->eatt_channels.begin(); while (iter != eatt_dev->eatt_channels.end()) { diff --git a/stack/test/eatt/eatt_test.cc b/stack/test/eatt/eatt_test.cc index 8e93227da..9eab9f47f 100644 --- a/stack/test/eatt/eatt_test.cc +++ b/stack/test/eatt/eatt_test.cc @@ -370,4 +370,12 @@ TEST_F(EattTest, ReconfigPeerFailed) { DisconnectEattDevice(); } + +TEST_F(EattTest, DoubleDisconnect) { + ConnectDeviceEattSupported(1); + DisconnectEattDevice(); + + /* Force second disconnect */ + eatt_instance_->Disconnect(test_address); +} } // namespace |