hal: miscellaneous fixes

Fixes for the following issues reported by KW

21725, 21726, 21727, 21737, 21738, 21739, 21740, 21750,
21751, 21752, 25317, 30602, 32620, 36778, 41817, 41819,
50942, 54468, 54470, 54479, 55569, 54481, 55570, 55571,
58485, 85112, 85122, 85123

Change-Id: I9abef07db7ccdc19789a201eb268a97e1b360cad
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index f853506..5ba3372 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -477,6 +477,11 @@
 {
     struct csd_data *csd = calloc(1, sizeof(struct csd_data));
 
+    if (!csd) {
+        ALOGE("failed to allocate csd_data mem");
+        return NULL;
+    }
+
     csd->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW);
     if (csd->csd_client == NULL) {
         ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT);
@@ -658,6 +663,11 @@
 
     my_data = calloc(1, sizeof(struct platform_data));
 
+    if (!my_data) {
+        ALOGE("failed to allocate platform data");
+        return NULL;
+    }
+
     while (snd_card_num < MAX_SND_CARD) {
         adev->mixer = mixer_open(snd_card_num);