primary-hal: Fix stability issues

Fixes to stability issues reported by static analysis tools.

Change-Id: Ief0057176170f6300a8521b1acfd706461f29244
This commit is contained in:
Aravind Siddappaji 2024-01-06 15:31:25 +05:30
parent e327f61c49
commit 4339e6958a
3 changed files with 22 additions and 12 deletions

View File

@ -5,7 +5,7 @@
* Copyright (C) 2013 The Android Open Source Project
*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -248,14 +248,14 @@ cleanup:
free(key_info);
}
if (my_data->acdb_init_data.snd_card_name)
free(my_data->acdb_init_data.snd_card_name);
if (result < 0) {
if (snd_card_name)
free((void *)snd_card_name);
if (my_data->acdb_init_data.snd_card_name)
free(my_data->acdb_init_data.snd_card_name);
if (my_data)
platform_info_deinit();
}

View File

@ -30,7 +30,7 @@
/*
* Changes from Qualcomm Innovation Center are provided under the following license:
*
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the
@ -1370,8 +1370,8 @@ static void* spkr_calibration_thread()
}
thermal_fd = open(wsa_path, O_RDONLY);
if (thermal_fd > 0) {
if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0) {
buf[ret-1] = '\0';
if ((ret = read(thermal_fd, buf, sizeof(buf)-1)) >= 0) {
buf[ret] = '\0';
t0_spk_1 = atoi(buf);
}
else
@ -1406,8 +1406,8 @@ static void* spkr_calibration_thread()
}
thermal_fd = open(wsa_path, O_RDONLY);
if (thermal_fd > 0) {
if ((ret = read(thermal_fd, buf, sizeof(buf))) >= 0) {
buf[ret-1] = '\0';
if ((ret = read(thermal_fd, buf, sizeof(buf)-1)) >= 0) {
buf[ret] = '\0';
t0_spk_2 = atoi(buf);
}
else

View File

@ -35,7 +35,7 @@
* limitations under the License.
*
* Changes from Qualcomm Innovation Center are provided under the following license:
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause-Clear
*
*/
@ -10811,8 +10811,13 @@ int adev_create_audio_patch(struct audio_hw_device *dev,
s_info = hashmapGet(adev->io_streams_map, (void *) (intptr_t) io_handle);
if (s_info == NULL) {
ALOGE("%s: Failed to obtain stream info", __func__);
if (new_patch)
if (new_patch) {
if(p_info->patch)
free(p_info->patch);
free(p_info);
}
pthread_mutex_unlock(&adev->lock);
ret = -EINVAL;
goto done;
@ -10833,8 +10838,13 @@ int adev_create_audio_patch(struct audio_hw_device *dev,
if (ret < 0) {
pthread_mutex_lock(&adev->lock);
s_info->patch_handle = AUDIO_PATCH_HANDLE_NONE;
if (new_patch)
if (new_patch) {
if(p_info->patch)
free(p_info->patch);
free(p_info);
}
pthread_mutex_unlock(&adev->lock);
ALOGE("%s: Stream routing failed for io_handle %d", __func__, io_handle);
goto done;