iris: Avoid leaking if we fail to allocate the aux buffer.
authorRafael Antognolli <rafael.antognolli@intel.com>
Fri, 15 Feb 2019 22:16:04 +0000 (14:16 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:12 +0000 (10:26 -0800)
Otherwise we could leak the aux state map or the aux BO.

src/gallium/drivers/iris/iris_resource.c

index 9c7420f2b4c836493a29b6c56bec4def577e66df..d305dbf34cfcd0e506bcf9ffcb0085b74ee0305a 100644 (file)
@@ -362,14 +362,18 @@ iris_resource_alloc_aux(struct iris_screen *screen, struct iris_resource *res)
                                      res->aux.surf.size_B,
                                      IRIS_MEMZONE_OTHER, I915_TILING_Y,
                                      res->aux.surf.row_pitch_B, alloc_flags);
-   if (!res->aux.bo)
+   if (!res->aux.bo) {
+      iris_resource_disable_aux(res);
       return false;
+   }
 
    /* Optionally, initialize the auxiliary data to the desired value. */
    if (memset_value != 0) {
       void *map = iris_bo_map(NULL, res->aux.bo, MAP_WRITE | MAP_RAW);
-      if (!map)
+      if (!map) {
+         iris_resource_disable_aux(res);
          return false;
+      }
 
       memset(map, memset_value, res->aux.surf.size_B);
       iris_bo_unmap(res->aux.bo);