Fix memory leak in WifiLegacyHal.

`WifiLegacyHal::getSupportedRadioCombinationsMatrix()`
allocs a buffer and returns it to
`WifiChip::getSupportedRadioCombinationsInternal()`, but
`WifiChip::getSupportedRadioCombinationsInternal()` never frees it.

Bug: 287883356
Test: manually test
Change-Id: I0e9d529e93cbb5fe254d48947661a2ae3d99d763
This commit is contained in:
Ye Jiao
2023-06-16 17:21:01 +08:00
committed by Gabriel Biren
parent fd1e1e58fc
commit 84310761ce

View File

@@ -1452,14 +1452,24 @@ WifiChip::getSupportedRadioCombinationsInternal() {
if (legacy_status != legacy_hal::WIFI_SUCCESS) {
LOG(ERROR) << "Failed to get SupportedRadioCombinations matrix from legacy HAL: "
<< legacyErrorToString(legacy_status);
if (legacy_matrix != nullptr) {
free(legacy_matrix);
}
return {aidl_combinations, createWifiStatusFromLegacyError(legacy_status)};
}
if (!aidl_struct_util::convertLegacyRadioCombinationsMatrixToAidl(legacy_matrix,
&aidl_combinations)) {
LOG(ERROR) << "Failed convertLegacyRadioCombinationsMatrixToAidl() ";
if (legacy_matrix != nullptr) {
free(legacy_matrix);
}
return {aidl_combinations, createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS)};
}
if (legacy_matrix != nullptr) {
free(legacy_matrix);
}
return {aidl_combinations, ndk::ScopedAStatus::ok()};
}