hal: Fix misc audio hal issues

- add array index range check when accessing pcm_device_table
- handle calloc failure
- avoid null pointer dereference

CRs-Fixed: 2456514
Change-Id: I2bedf0f1015e646973acba17297267eb317949ce
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index ace49a0..80a52c7 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -3054,6 +3054,10 @@
 {
     int device_id = -1;
 
+    if ((usecase >= AUDIO_USECASE_MAX) || (usecase <= USECASE_INVALID)) {
+        ALOGE("%s: invalid usecase case idx %d", __func__, usecase);
+        return device_id;
+    }
     if (device_type == PCM_PLAYBACK)
         device_id = pcm_device_table[usecase][0];
     else