policy_hal: fix possible NULL dereference reported in KW reports
Fix possible NULL dereference in custom policy manager inside method
getOutputForDevice().
Change-Id: I643d5e8401b03973284cef06820cc1cc914b0658
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 6d2189f..e8086da 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1791,16 +1791,16 @@
}
}
}
- if (flags == AUDIO_OUTPUT_FLAG_DIRECT &&
- direct_pcm_already_in_use == true &&
- session != outputDesc->mDirectClientSession) {
- ALOGV("getOutput() do not reuse direct pcm output because current client (%d) "
- "is not the same as requesting client (%d) for different output conf",
- outputDesc->mDirectClientSession, session);
- goto non_direct_output;
- }
// close direct output if currently open and configured with different parameters
if (outputDesc != NULL) {
+ if (flags == AUDIO_OUTPUT_FLAG_DIRECT &&
+ direct_pcm_already_in_use == true &&
+ session != outputDesc->mDirectClientSession) {
+ ALOGV("getOutput() do not reuse direct pcm output because current client (%d) "
+ "is not the same as requesting client (%d) for different output conf",
+ outputDesc->mDirectClientSession, session);
+ goto non_direct_output;
+ }
closeOutput(outputDesc->mIoHandle);
}
}