Merge "audiopolicy: align custom APM with AOSP" into av-aosp-qc.lnx.10.0
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 698136b..dac096c 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1969,6 +1969,11 @@
 
     audio_io_handle_t input = inputDesc->mIoHandle;
     sp<RecordClientDescriptor> client = inputDesc->getClient(portId);
+    if (client == NULL) {
+        ALOGW("%s invalid client desc for %d", __FUNCTION__, portId);
+        return BAD_VALUE;
+    }
+
     if (client->active()) {
         ALOGW("%s input %d client %d already started", __FUNCTION__, input, client->portId());
         return INVALID_OPERATION;