hal: Fix potential NULL dereference
Fix potential NULL dereference of active input stream.
Change-Id: I65287fe928d1a357f0bba9696af008bd2eaec870
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 9b7bd1f..3425175 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -919,6 +919,11 @@
long set_values[6];
struct stream_in *in = adev_get_active_input(adev);
+ if (in == NULL) {
+ ALOGE("%s: active input stream is NULL", __func__);
+ return -EINVAL;
+ }
+
ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
if (!ctl) {
ALOGE("%s: Could not get mixer ctl - %s",
@@ -947,6 +952,11 @@
struct audio_usecase *usecase = NULL;
struct stream_in *in = adev_get_active_input(adev);
+ if (in == NULL) {
+ ALOGE("%s: active input stream is NULL", __func__);
+ return -EINVAL;
+ }
+
usecase = get_usecase_from_list(adev, in->usecase);
if (!usecase)
return -EINVAL;