agm: ipc: SWBinders: protect handle by clbk_data_list_lock

Secure the handle with clbk_data_list_lock to prevent
its unauthorized use after it has been released.

Change-Id: I101df6ddaf9f9bb4b5c836450a17eb6e0c8b7d59
diff --git a/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp b/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
index 82cd647..0f875ea 100644
--- a/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
+++ b/ipc/SwBinders/agm_server/src/ipc_proxy_server.cpp
@@ -27,7 +27,7 @@
 ** 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.
+ * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted (subject to the limitations in the
@@ -777,21 +777,21 @@
         if (handle != NULL && handle->session_id == session_id &&
                               handle->client_data == client_data) {
             AGM_LOGV("%s: Found handle %p\n", __func__, handle);
-            pthread_mutex_unlock(&clbk_data_list_lock);
             break;
         }
     }
-    pthread_mutex_unlock(&clbk_data_list_lock);
 
     if (handle!= NULL) {
         sp<ICallback> cb_binder = handle->cb_binder;
         if (cb_binder == NULL) {
             AGM_LOGE("%s Invalid binder handle\n", __func__);
+            pthread_mutex_unlock(&clbk_data_list_lock);
             return;
         }
         cb_binder->event_cb(session_id, event_params,
                handle->client_data, handle->cb_func);
     }
+    pthread_mutex_unlock(&clbk_data_list_lock);
 }