summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Katherine Lai <laikatherine@google.com> 2025-02-26 08:40:24 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-02-26 08:40:24 -0800
commit15d4ffe9104a20ff8423ba3c663c00f9ee933cda (patch)
treed1a3490cbe84e0b817ce372d523d0184ad0d3c1c
parent919f4c5b9c27664d0f49087af5cc2a3f0a5b8298 (diff)
parentda5c593141264399396383074008009daed50dc4 (diff)
Merge "system/gd/hci: Update MSFT to not crash on read feature failure" into main
-rw-r--r--system/gd/hci/msft.cc26
1 files changed, 10 insertions, 16 deletions
diff --git a/system/gd/hci/msft.cc b/system/gd/hci/msft.cc
index b27bcf23d5..1c5a700030 100644
--- a/system/gd/hci/msft.cc
+++ b/system/gd/hci/msft.cc
@@ -56,10 +56,13 @@ struct MsftExtensionManager::impl {
* Query the kernel/drivers to derive the MSFT opcode so that
* we can issue MSFT vendor specific commands.
*/
- if (!supports_msft_extensions()) {
+ uint16_t opcode = hal_->getMsftOpcode();
+ if (opcode == 0) {
log::info("MSFT extension is not supported.");
return;
}
+ msft_.opcode = opcode;
+ log::info("MSFT opcode 0x{:04x}", msft_.opcode.value());
/*
* The vendor prefix is required to distinguish among the vendor events
@@ -121,20 +124,7 @@ struct MsftExtensionManager::impl {
}
}
- bool supports_msft_extensions() {
- if (msft_.opcode.has_value()) {
- return true;
- }
-
- uint16_t opcode = hal_->getMsftOpcode();
- if (opcode == 0) {
- return false;
- }
-
- msft_.opcode = opcode;
- log::info("MSFT opcode 0x{:04x}", msft_.opcode.value());
- return true;
- }
+ bool supports_msft_extensions() { return msft_.opcode.has_value(); }
void msft_adv_monitor_add(const MsftAdvMonitor& monitor, MsftAdvMonitorAddCallback cb) {
if (!supports_msft_extensions()) {
@@ -225,7 +215,11 @@ struct MsftExtensionManager::impl {
log::assert_that(view.IsValid(), "assert failed: view.IsValid()");
auto status_view = MsftReadSupportedFeaturesCommandCompleteView::Create(
MsftCommandCompleteView::Create(view));
- log::assert_that(status_view.IsValid(), "assert failed: status_view.IsValid()");
+ if (!status_view.IsValid()) {
+ log::error("MSFT Read supported features failed");
+ msft_.opcode = std::nullopt;
+ return;
+ }
if (status_view.GetStatus() != ErrorCode::SUCCESS) {
log::warn("MSFT Command complete status {}", ErrorCodeText(status_view.GetStatus()));