From dec38700bbd06c1a5f52875e2cff1b54c0b23505 Mon Sep 17 00:00:00 2001 From: Ye Jiao Date: Fri, 10 Feb 2023 11:37:58 +0800 Subject: [PATCH] Fix multi-link llstat parsing in wifi legacy hal Multi-link llstat parsing codes in wifi legacy hal, specifically 'copyLinkStat' and 'copyPeerInfo', pass the output container parameter 'std::vector<>' by value instead of by reference. The result is the copied 'LinkStats' list and 'WifiPeerInfo' list are discarded when 'copyLinkStat' and 'copyPeerInfo' return. The empty links list are passed to framework and fails validity check in Wi-Fi framework and leads to system server crash. Fix this issue by passing 'stats' and 'peers' by reference. Bug: 269049672 Test: Manual Test with multi-link llstat implementation integrated Change-Id: If8c366213af2ffcb9f7b3c904e1541ed0ac2fea4 --- wifi/aidl/default/wifi_legacy_hal.cpp | 4 ++-- wifi/aidl/default/wifi_legacy_hal.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wifi/aidl/default/wifi_legacy_hal.cpp b/wifi/aidl/default/wifi_legacy_hal.cpp index 43a71cc074..5e64b85e05 100644 --- a/wifi/aidl/default/wifi_legacy_hal.cpp +++ b/wifi/aidl/default/wifi_legacy_hal.cpp @@ -745,7 +745,7 @@ wifi_error WifiLegacyHal::disableLinkLayerStats(const std::string& iface_name) { // Copies wifi_peer_info* to vector and returns poiner to next element. wifi_peer_info* WifiLegacyHal::copyPeerInfo(wifi_peer_info* peer_ptr, - std::vector peers) { + std::vector& peers) { WifiPeerInfo peer; peer.peer_info = *peer_ptr; if (peer_ptr->num_rate > 0) { @@ -761,7 +761,7 @@ wifi_peer_info* WifiLegacyHal::copyPeerInfo(wifi_peer_info* peer_ptr, } // Copies wifi_link_stat* to vector and returns poiner to next element. wifi_link_stat* WifiLegacyHal::copyLinkStat(wifi_link_stat* stat_ptr, - std::vector stats) { + std::vector& stats) { LinkStats linkStat; linkStat.stat = *stat_ptr; wifi_peer_info* l_peer_info_stats_ptr = stat_ptr->peer_info; diff --git a/wifi/aidl/default/wifi_legacy_hal.h b/wifi/aidl/default/wifi_legacy_hal.h index a066ea6083..146359dc67 100644 --- a/wifi/aidl/default/wifi_legacy_hal.h +++ b/wifi/aidl/default/wifi_legacy_hal.h @@ -782,8 +782,8 @@ class WifiLegacyHal { // Handles wifi (error) status of Virtual interface create/delete wifi_error handleVirtualInterfaceCreateOrDeleteStatus(const std::string& ifname, wifi_error status); - wifi_link_stat* copyLinkStat(wifi_link_stat* stat_ptr, std::vector stats); - wifi_peer_info* copyPeerInfo(wifi_peer_info* peer_ptr, std::vector peers); + wifi_link_stat* copyLinkStat(wifi_link_stat* stat_ptr, std::vector& stats); + wifi_peer_info* copyPeerInfo(wifi_peer_info* peer_ptr, std::vector& peers); // Global function table of legacy HAL. wifi_hal_fn global_func_table_;