vc4: Fix a memory leak in the simulator case.
authorEric Anholt <eric@anholt.net>
Tue, 6 Oct 2015 23:12:50 +0000 (16:12 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 6 Oct 2015 23:29:14 +0000 (16:29 -0700)
We validate per draw call, and need to free the shader per draw call, too.

src/gallium/drivers/vc4/vc4_simulator.c

index 7cfd236349d3fc6b09a1bf7d4af69ab89e49b3d4..76980ca32af8c8fc1e7dc54bc3299152e9319c1e 100644 (file)
@@ -106,10 +106,15 @@ vc4_simulator_unpin_bos(struct vc4_exec_info *exec)
 {
         for (int i = 0; i < exec->bo_count; i++) {
                 struct drm_gem_cma_object *obj = exec->bo[i];
-                struct vc4_bo *bo = to_vc4_bo(&obj->base)->bo;
+                struct drm_vc4_bo *drm_bo = to_vc4_bo(&obj->base);
+                struct vc4_bo *bo = drm_bo->bo;
 
                 memcpy(bo->map, obj->vaddr, bo->size);
 
+                if (drm_bo->validated_shader) {
+                        free(drm_bo->validated_shader->texture_samples);
+                        free(drm_bo->validated_shader);
+                }
                 free(obj);
         }