Merge 381794fc97db106ee4e47f711c7adcd156260685 on remote branch

Change-Id: I51ba8bcad72599fa1de3fefd7e0afd1fddec9a45
diff --git a/hal/audio_extn/keep_alive.c b/hal/audio_extn/keep_alive.c
index 2948402..7d8951a 100644
--- a/hal/audio_extn/keep_alive.c
+++ b/hal/audio_extn/keep_alive.c
@@ -25,6 +25,11 @@
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+* Changes from Qualcomm Innovation Center are provided under the following license:
+*
+* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+* SPDX-License-Identifier: BSD-3-Clause-Clear
 */
 
 #define LOG_TAG "keep_alive"
@@ -198,13 +203,14 @@
     struct listnode out_devices;
 
     pthread_mutex_lock(&ka.lock);
+    list_init(&out_devices);
+
     ALOGV("%s: mode %x", __func__, ka_mode);
     if ((ka.state == STATE_DISABLED)||(ka.state == STATE_DEINIT)) {
         ALOGE(" %s : Unexpected state %x",__func__, ka.state);
         goto exit;
     }
 
-    list_init(&out_devices);
     get_device_id_from_mode(ka_mode, &out_devices);
     if (compare_devices(&out_devices, &ka.active_devices) &&
             (ka.state == STATE_ACTIVE)) {