hal: Add clear_devices to avoid memory leakage

In case of device update, it will alloc memory for new device,
Add the corresponding clear_devices to avoid the memory leakage.

Change-Id: If8498bad04146f383073e521a7d74fe20564f880
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index d7c4b03..5d573d0 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -587,6 +587,7 @@
                                   __func__, event, snd_device);
         }
     }/*Events for output device, if required can be placed here in else*/
+    clear_devices(&ev_info.device_info.devices);
 }
 
 void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info,
@@ -645,6 +646,7 @@
             }
         }
     }
+    clear_devices(&ev_info.device_info.devices);
 }
 
 void audio_extn_sound_trigger_update_battery_status(bool charging)
@@ -874,6 +876,7 @@
     if (st_dev && (st_dev->adev == adev) && st_dev->lib_handle) {
         audio_extn_snd_mon_unregister_listener(st_dev);
         dlclose(st_dev->lib_handle);
+        clear_devices(&st_dev->st_ses_list);
         free(st_dev);
         st_dev = NULL;
     }