diff options
author | Vasyl Gello <vasek.gello@gmail.com> | 2018-07-01 10:57:35 +0300 |
---|---|---|
committer | Simon Shields <simon@lineageos.org> | 2018-07-25 09:41:39 +0200 |
commit | 0095f3df328f33e6f48062725ae20e8f8ded1d70 (patch) | |
tree | e042e1e7df8ec1664385d93de36463206f63b41b | |
parent | 41069235e8f80724107035b592965f6b1c434023 (diff) | |
download | android_hardware_samsung-0095f3df328f33e6f48062725ae20e8f8ded1d70.tar.gz android_hardware_samsung-0095f3df328f33e6f48062725ae20e8f8ded1d70.tar.bz2 android_hardware_samsung-0095f3df328f33e6f48062725ae20e8f8ded1d70.zip |
audio_hw: Prevent referencing input devices from empty list
Fixes audioserver crash in in_get_capture_position() if PCM input
device was not properly opened.
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Change-Id: I2f2d9bc8151cf61af112a9544268513effacacb5
-rw-r--r-- | audio/audio_hw.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c index d28dc30..042a12d 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -1176,6 +1176,11 @@ static int32_t update_echo_reference(struct stream_in *in, size_t frames) b.delay_ns = 0; struct pcm_device *pcm_device; + if (list_empty(&in->pcm_dev_list)) { + ALOGW("%s: pcm device list empty", __func__); + return b.delay_ns; + } + pcm_device = node_to_item(list_head(&in->pcm_dev_list), struct pcm_device, stream_list_node); @@ -3479,6 +3484,11 @@ static int in_get_capture_position(const struct audio_stream_in *stream, struct pcm_device *pcm_device; int ret = -ENOSYS; + if (list_empty(&in->pcm_dev_list)) { + ALOGW("%s: pcm device list empty", __func__); + return -ENODEV; + } + pcm_device = node_to_item(list_head(&in->pcm_dev_list), struct pcm_device, stream_list_node); |