wlan: Fix for driver crash if the nv file is old.

The reason wlan driver crashes if the WCNSS_qcom_wlan_nv.bin file is old
is because the driver reads the nv items from the file and typecast the
read data to the structure nvEFSTable_t, but the structure has modified
to accommodate new rates in the latest driver and now since the
structure mismatch the data gets corrupted and while copying the nv
items which was read from nv files to the global variable pnvEFSTable
causing the crash. If the nv items in the file is different than the
sizeof(nvEFSTable_t) then only copy the default nv items and return.

Change-Id: I052abf1661df2bd85a458f10a24e10ceb27a99e8
CR-Fixed: 400823
diff --git a/CORE/VOSS/src/vos_nvitem.c b/CORE/VOSS/src/vos_nvitem.c
index b18d133..fed6e8b 100644
--- a/CORE/VOSS/src/vos_nvitem.c
+++ b/CORE/VOSS/src/vos_nvitem.c
@@ -52,6 +52,9 @@
 #define MAX_COUNTRY_COUNT        300
 //To be removed when NV support is fully functional
 #define VOS_HARD_CODED_MAC    {0, 0x0a, 0xf5, 4, 5, 6}
+
+#define DEFAULT_NV_VALIDITY_BITMAP 0xFFFFFFFF
+
 /*----------------------------------------------------------------------------
  * Type Declarations
  * -------------------------------------------------------------------------*/
@@ -463,6 +466,7 @@
     VOS_STATUS status = VOS_STATUS_SUCCESS;
     v_CONTEXT_t pVosContext= NULL;
     v_SIZE_t bufSize;
+    v_SIZE_t nvReadBufSize;
     v_BOOL_t itemIsValid = VOS_FALSE;
     
     /*Get the global context */
@@ -470,7 +474,7 @@
     bufSize = sizeof(nvEFSTable_t);
     status = hdd_request_firmware(WLAN_NV_FILE,
                                   ((VosContextType*)(pVosContext))->pHDDContext,
-                                  (v_VOID_t**)&gnvEFSTable, &bufSize);
+                                  (v_VOID_t**)&gnvEFSTable, &nvReadBufSize);
 
     if ( (!VOS_IS_STATUS_SUCCESS( status )) || !gnvEFSTable)
     {
@@ -493,8 +497,17 @@
 
         /*Copying the NV defaults */
         vos_mem_copy(&(pnvEFSTable->halnv),&nvDefaults,sizeof(sHalNv));
-        pnvEFSTable->nvValidityBitmap = gnvEFSTable->nvValidityBitmap;
+       
+        if ( nvReadBufSize != bufSize)
+        {
+            pnvEFSTable->nvValidityBitmap = DEFAULT_NV_VALIDITY_BITMAP;
+            VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
+                      "!!!WARNING: INVALID NV FILE, DRIVER IS USING DEFAULT CAL VALUES %d %d!!!",
+                      nvReadBufSize, bufSize);
+            return (eHAL_STATUS_SUCCESS);
+        }
 
+       pnvEFSTable->nvValidityBitmap = gnvEFSTable->nvValidityBitmap;
         /* Copy the valid fields to the NV Global structure */ 
         if (vos_nv_getValidity(VNV_FIELD_IMAGE, &itemIsValid) == 
            VOS_STATUS_SUCCESS)