hal: handle null primary output scenario
Handle NULL primary output scenario to avoid crash.
CRs-Fixed: 2782413
Change-Id: I4c1ba663bb21583b6fa76d68461d5e16248aec90
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 12e89dc..f7cef09 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -9073,7 +9073,7 @@
ALOGD("%s: mode %d , prev_mode %d \n", __func__, mode , adev->mode);
adev->prev_mode = adev->mode; /* prev_mode is kept to handle voip concurrency*/
adev->mode = mode;
- if( mode == AUDIO_MODE_CALL_SCREEN ){
+ if (mode == AUDIO_MODE_CALL_SCREEN) {
adev->current_call_output = adev->primary_output;
voice_start_call(adev);
} else if (voice_is_in_call_or_call_screen(adev) &&
diff --git a/hal/voice.c b/hal/voice.c
index 72c3372..586247f 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -231,6 +231,11 @@
return -EINVAL;
}
+ if (!adev->current_call_output) {
+ ALOGE("start_call: invalid current call output");
+ return -EINVAL;
+ }
+
uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
if (!uc_info) {
ALOGE("start_call: couldn't allocate mem for audio_usecase");