tinyalsa: check for NULL mmap_status
pcm_mmap_get_hw_ptr() was not checking pcm->mmap_status and
crashed when it was NULL.
Bug: 64346189
Test: input_monitor.cpp, see bug report for repro steps
Change-Id: I8436686a231eb01a82dd28ca2cce561d5460bcd6
diff --git a/pcm.c b/pcm.c
index 614a14e..120d182 100644
--- a/pcm.c
+++ b/pcm.c
@@ -500,6 +500,9 @@
if (rc < 0)
return oops(pcm, errno, "pcm_sync_ptr failed");
+ if (pcm->mmap_status == NULL)
+ return oops(pcm, EINVAL, "pcm %p, mmap_status is NULL", pcm);
+
if ((pcm->mmap_status->state != PCM_STATE_RUNNING) &&
(pcm->mmap_status->state != PCM_STATE_DRAINING))
return oops(pcm, ENOSYS, "invalid stream state %d", pcm->mmap_status->state);