audio-hal: handling resource leak for variable 'params'

Variable “params” will not be released if it is returned directly.
So added return variable and released params before calling return.

Change-Id: I3c39e397402eaf1792d43b8fbe6765e8b36fc831
diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c
index 930c95e..5e39d37 100644
--- a/hal/audio_extn/sndmonitor.c
+++ b/hal/audio_extn/sndmonitor.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -430,10 +430,13 @@
     snprintf(val, sizeof(val), "%s,%s", dev_event->dev,
              dev_event->status ? "ON" : "OFF");
 
-    if (str_parms_add_str(params, AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE, val) < 0)
-        return -1;
+    int ret = 0;
 
-    int ret = notify(params);
+    if (str_parms_add_str(params, AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE, val) < 0) {
+        ret = -1;
+    } else {
+        ret = notify(params);
+    }
     str_parms_destroy(params);
     return ret;
 }
@@ -484,10 +487,13 @@
     key = (is_cpe ?  "CPE_STATUS" :
           (is_slpi ? "SLPI_STATUS" :
                      "SND_CARD_STATUS"));
-    if (str_parms_add_str(params, key, val) < 0)
-        return -1;
 
-    int ret = notify(params);
+    int ret = 0;
+    if (str_parms_add_str(params, key, val) < 0) {
+        ret = -1;
+    } else {
+        ret = notify(params);
+    }
     str_parms_destroy(params);
     return ret;
 }