diff options
author | 2025-03-17 21:48:53 -0700 | |
---|---|---|
committer | 2025-03-18 10:22:19 -0700 | |
commit | 52766777e7f62a0fcda859394a7949e15a262b9f (patch) | |
tree | a914517dd67c016f51781cc56529a29fd685216e /system | |
parent | 821316396f83f15d597acf99fa5b1419461b3286 (diff) |
Check for invalid handle before looking up device by handle
When invalid connection handle is passed to btm_find_dev_by_handle(), it returns the first device which does not have any of the transports connected.
Test: mmm packages/modules/Bluetooth
Flag: EXEMPT trivial fix
Bug: 399122843
Change-Id: Idedd4a65ed4517ae6bee7efda9b0f87b7096a8c2
Diffstat (limited to 'system')
-rw-r--r-- | system/stack/btm/btm_dev.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/system/stack/btm/btm_dev.cc b/system/stack/btm/btm_dev.cc index 92dc80e1ab..992a59236c 100644 --- a/system/stack/btm/btm_dev.cc +++ b/system/stack/btm/btm_dev.cc @@ -326,6 +326,10 @@ static bool is_handle_equal(void* data, void* context) { * ******************************************************************************/ tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle) { + if (handle == HCI_INVALID_HANDLE) { + return nullptr; + } + if (btm_sec_cb.sec_dev_rec == nullptr) { return nullptr; } @@ -335,7 +339,7 @@ tBTM_SEC_DEV_REC* btm_find_dev_by_handle(uint16_t handle) { return static_cast<tBTM_SEC_DEV_REC*>(list_node(n)); } - return NULL; + return nullptr; } static bool is_not_same_identity_or_pseudo_address(void* data, void* context) { |