loader: Handle OOM in loader_phys_dev_ext_gpa
authorCharles Giessen <charles@lunarg.com>
Wed, 12 May 2021 23:42:00 +0000 (17:42 -0600)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Thu, 9 Sep 2021 18:15:49 +0000 (12:15 -0600)
Removing some dead code revealed a case where a potencial OOM situation
was not being handled.

Change-Id: Ibc5ad607f6adc0f590f663ab928c1abca6732d96

loader/loader.c

index ab50f7257f56307c75a2e5412a54303487369c02..cd7c63ff20090e874e4a4d5b5874a292631e7080 100644 (file)
@@ -4329,12 +4329,12 @@ bool loader_phys_dev_ext_gpa(struct loader_instance *inst, const char *funcName,
     idx = murmurhash(funcName, strlen(funcName), seed) % MAX_NUM_UNKNOWN_EXTS;
     if (perform_checking && !loader_name_in_phys_dev_ext_table(inst, &idx, funcName)) {
         uint32_t i;
-        bool added = false;
 
         // Only need to add first one to get index in Instance.  Others will use
         // the same index.
-        if (!added && loader_add_phys_dev_ext_table(inst, &idx, funcName)) {
-            added = true;
+        if (!loader_add_phys_dev_ext_table(inst, &idx, funcName)) {
+            // couldn't perform the above function due to insufficient memory available
+            goto out;
         }
 
         // Setup the ICD function pointers