Merge "service: Fix copyright markings"
diff --git a/plugins/tinyalsa/src/agm_mixer_plugin.c b/plugins/tinyalsa/src/agm_mixer_plugin.c
index cb85c9d..1cd1e16 100644
--- a/plugins/tinyalsa/src/agm_mixer_plugin.c
+++ b/plugins/tinyalsa/src/agm_mixer_plugin.c
@@ -1485,6 +1485,7 @@
     free(pcm_adi->get_param_info[idx].get_param_payload);
     pcm_adi->get_param_info[idx].get_param_payload = NULL;
     pcm_adi->get_param_info[idx].get_param_payload_size = 0;
+    errno = ret;
     return ret;
 }
 
diff --git a/service/src/session_obj.c b/service/src/session_obj.c
index 8b9ad19..1ae4057 100644
--- a/service/src/session_obj.c
+++ b/service/src/session_obj.c
@@ -1698,9 +1698,9 @@
         ckv.num_kvs = cal_config->num_ckvs;
         metadata_update_cal(&sess_obj->sess_meta, &ckv);
         metadata_update_cal(&aif_obj->sess_aif_meta, &ckv);
+        pthread_mutex_lock(&aif_obj->dev_obj->lock);
         metadata_update_cal(&aif_obj->dev_obj->metadata, &ckv);
 
-        pthread_mutex_lock(&aif_obj->dev_obj->lock);
         merged_metadata = metadata_merge(3, &sess_obj->sess_meta,
                           &aif_obj->sess_aif_meta, &aif_obj->dev_obj->metadata);
         pthread_mutex_unlock(&aif_obj->dev_obj->lock);
@@ -2308,7 +2308,6 @@
             sess_cb->cb(sess_obj->sess_id,
                         (struct agm_event_cb_params *)event_params,
                         sess_cb->client_data);
-            break;
         }
     }
     pthread_mutex_unlock(&sess_obj->cb_pool_lock);
diff --git a/snd_parser/src/snd-card-parser.c b/snd_parser/src/snd-card-parser.c
index 37824e6..96b8776 100644
--- a/snd_parser/src/snd-card-parser.c
+++ b/snd_parser/src/snd-card-parser.c
@@ -25,6 +25,10 @@
 ** 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) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+*  SPDX-License-Identifier: BSD-3-Clause-Clear
 **/
 
 #include <errno.h>
@@ -486,7 +490,8 @@
         if (card_found) {
             card_def->refcnt++;
             pthread_rwlock_unlock(&snd_rwlock);
-            free(snd_card_name);
+            if (snd_card_name != NULL)
+               free(snd_card_name);
             return card_def;
         }
     }
@@ -496,7 +501,8 @@
     file = fopen(CARD_DEF_FILE, "r");
     if (!file) {
         pthread_rwlock_unlock(&snd_rwlock);
-        free(snd_card_name);
+        if (snd_card_name != NULL )
+           free(snd_card_name);
         return NULL;
     }
 
@@ -504,7 +510,8 @@
     if (!parser) {
         fclose(file);
         pthread_rwlock_unlock(&snd_rwlock);
-        free(snd_card_name);
+        if (snd_card_name != NULL)
+           free(snd_card_name);
         return NULL;
     }
 
@@ -539,7 +546,8 @@
         card_def->refcnt++;
     }
 ret:
-    free(snd_card_name);
+    if (snd_card_name != NULL)
+       free(snd_card_name);
     card_data.card_name = NULL;
     XML_ParserFree(parser);
     fclose(file);