summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Warner <Tortel1210@gmail.com>2020-04-02 11:28:07 -0400
committerLuK1337 <priv.luk@gmail.com>2020-05-18 14:11:15 +0200
commit12480be3c8902cc9a24d4810eb7ea0da9487846d (patch)
treefc9ff761066aa6c725ba8286bd8bb7ebc0b9167c
parent72fccd62ade47e9f3a59b4ded1f3c86dfe6b1cbe (diff)
downloadhardware_qcom_audio-lineage-17.1-caf-sm8150.tar.gz
hardware_qcom_audio-lineage-17.1-caf-sm8150.tar.bz2
hardware_qcom_audio-lineage-17.1-caf-sm8150.zip
a2dp: Add a null check before iterating over a2dp.adev->usecase_listlineage-17.1-caf-sm8150
Prevents audioservice from crashing when trying to switch an incoming phone call to a bluetooth headset Change-Id: I130f2fe5f1f15fa61ea3075c4f32b978eef609b3
-rw-r--r--hal/audio_extn/a2dp.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index 14bf29c4..eb5a5546 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -2792,13 +2792,15 @@ int a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
a2dp.a2dp_source_suspended = true;
if (a2dp.bt_state_source == A2DP_STATE_DISCONNECTED)
goto param_handled;
- list_for_each(node, &a2dp.adev->usecase_list) {
- uc_info = node_to_item(node, struct audio_usecase, list);
- if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
- (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
- pthread_mutex_unlock(&a2dp.adev->lock);
- fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
- pthread_mutex_lock(&a2dp.adev->lock);
+ if (a2dp.adev->usecase_list.next != NULL) {
+ list_for_each(node, &a2dp.adev->usecase_list) {
+ uc_info = node_to_item(node, struct audio_usecase, list);
+ if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
+ (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
+ pthread_mutex_unlock(&a2dp.adev->lock);
+ fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, false);
+ pthread_mutex_lock(&a2dp.adev->lock);
+ }
}
}
if (!a2dp.swb_configured)
@@ -2833,13 +2835,15 @@ int a2dp_set_parameters(struct str_parms *parms, bool *reconfig)
}
}
}
- list_for_each(node, &a2dp.adev->usecase_list) {
- uc_info = node_to_item(node, struct audio_usecase, list);
- if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
- (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
- pthread_mutex_unlock(&a2dp.adev->lock);
- fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);
- pthread_mutex_lock(&a2dp.adev->lock);
+ if (a2dp.adev->usecase_list.next != NULL) {
+ list_for_each(node, &a2dp.adev->usecase_list) {
+ uc_info = node_to_item(node, struct audio_usecase, list);
+ if (uc_info->stream.out && uc_info->type == PCM_PLAYBACK &&
+ (uc_info->stream.out->devices & AUDIO_DEVICE_OUT_ALL_A2DP)) {
+ pthread_mutex_unlock(&a2dp.adev->lock);
+ fp_check_a2dp_restore(a2dp.adev, uc_info->stream.out, true);
+ pthread_mutex_lock(&a2dp.adev->lock);
+ }
}
}
}