Merge cherrypicks of [3166006, 3165952, 3164925, 3164926, 3164927, 3164928, 3167313, 3167314, 3167315, 3167316, 3167317, 3167318, 3167319, 3167320, 3167321, 3167322, 3166318, 3166319, 3166320, 3166321, 3166322, 3166323, 3166324, 3167333, 3167334, 3167373, 3165112, 3166325, 3165229, 3165230] into nyc-mr2-release

Change-Id: I021f1a3719f16c3ea2e9b47d3a5c039f5a83a1ca
diff --git a/bta/gatt/bta_gattc_cache.c b/bta/gatt/bta_gattc_cache.c
index 63c4246..45d2588 100644
--- a/bta/gatt/bta_gattc_cache.c
+++ b/bta/gatt/bta_gattc_cache.c
@@ -1551,7 +1551,7 @@
 
     attr = osi_malloc(sizeof(tBTA_GATTC_NV_ATTR) * num_attr);
 
-    if (fread(attr, sizeof(tBTA_GATTC_NV_ATTR), 0xFF, fd) != num_attr) {
+    if (fread(attr, sizeof(tBTA_GATTC_NV_ATTR), num_attr, fd) != num_attr) {
         APPL_TRACE_ERROR("%s: can't read GATT attributes: %s", __func__, fname);
         goto done;
     }