hal: Fix race condition in parsing platform info xml

Section is a global variable in platform info parsing functions and
both platform and acdb_extn will call into platform_info_init(). As
a result, there's a race condition happening.

Adding mutex lock to ensure file parsing in atomic.

CRs-Fixed: 2521912
Change-Id: Ic323618057ca2dc21ff60d280cb7a6de3a3271ed
diff --git a/hal/platform_info.c b/hal/platform_info.c
index d73792c..1969f52 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -135,6 +135,7 @@
 };
 
 static struct platform_info my_data;
+static pthread_mutex_t parser_lock = PTHREAD_MUTEX_INITIALIZER;
 
 
 struct audio_string_to_enum {
@@ -1447,6 +1448,7 @@
     void            *buf;
     char            platform_info_file_name[MIXER_PATH_MAX_LENGTH]= {0};
 
+    pthread_mutex_lock(&parser_lock);
     if (filename == NULL)
         strlcpy(platform_info_file_name, PLATFORM_INFO_XML_PATH,
                 MIXER_PATH_MAX_LENGTH);
@@ -1511,5 +1513,6 @@
 err_close_file:
     fclose(file);
 done:
+    pthread_mutex_unlock(&parser_lock);
     return ret;
 }