hal: Fix NULL dereferences in audio hal utils

Fix potential NULL dereference issues in audio hal extension utils.

CRs-Fixed: 2053298
Change-Id: I12996fd1a256240c19ba2d997169e895e56946e1
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 4bff170..518acd6 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -1760,7 +1760,12 @@
     struct stream_out *out = NULL;
     int ret = -EINVAL;
 
-    if (usecase != NULL && usecase->type != PCM_PLAYBACK) {
+    if (usecase == NULL) {
+        ALOGE("%s:: Invalid use case", __func__);
+        goto exit;
+    }
+
+    if (usecase->type != PCM_PLAYBACK) {
         ALOGE("%s:: Invalid use case", __func__);
         goto exit;
     }
@@ -1828,14 +1833,14 @@
     struct snd_compr_metadata metadata;
     int ret = -EINVAL;
 
-    ALOGD("%s:: render window start 0x%"PRIx64" end 0x%"PRIx64"",
-          __func__,render_window->render_ws, render_window->render_we);
-
     if(render_window == NULL) {
         ALOGE("%s:: Invalid render_window", __func__);
         goto exit;
     }
 
+    ALOGD("%s:: render window start 0x%"PRIx64" end 0x%"PRIx64"",
+          __func__,render_window->render_ws, render_window->render_we);
+
     if (!is_offload_usecase(out->usecase)) {
         ALOGE("%s:: not supported for non offload session", __func__);
         goto exit;