hal: add NULL check for stream in
Add a null check for stream in to avoid crashes during
voice call recording and other use cases which involve
capture path.
CRs-Fixed: 2010691
Change-Id: Ifc23bb837804d9500a1b9c5164f79fa085b20a34
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index f887904..d18ab88 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -5494,9 +5494,9 @@
/* update cfg against other existing capture usecases on same backend */
list_for_each(node, &adev->usecase_list) {
uc = node_to_item(node, struct audio_usecase, list);
- if (uc->type == PCM_CAPTURE &&
+ in = (struct stream_in *) uc->stream.in;
+ if (in != NULL && uc->type == PCM_CAPTURE &&
backend_idx == platform_get_backend_index(uc->in_snd_device)) {
- in = (struct stream_in *) uc->stream.in;
uc_channels = audio_channel_count_from_in_mask(in->channel_mask);
ALOGV("%s:txbecf: uc %s, id %d, sr %d, bw %d, ch %d, device %s",
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 93b28ca..22ce6ba 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -5360,9 +5360,9 @@
/* update cfg against other existing capture usecases on same backend */
list_for_each(node, &adev->usecase_list) {
uc = node_to_item(node, struct audio_usecase, list);
- if (uc->type == PCM_CAPTURE &&
+ in = (struct stream_in *) uc->stream.in;
+ if (in != NULL && uc->type == PCM_CAPTURE &&
backend_idx == platform_get_backend_index(uc->in_snd_device)) {
- in = (struct stream_in *) uc->stream.in;
uc_channels = audio_channel_count_from_in_mask(in->channel_mask);
ALOGV("%s:txbecf: uc %s, id %d, sr %d, bw %d, ch %d, device %s",