broadcom/vc4: Fix use-after-free for flushing when writing to a texture.
authorEric Anholt <eric@anholt.net>
Mon, 18 Sep 2017 21:52:32 +0000 (14:52 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 18 Sep 2017 23:15:58 +0000 (16:15 -0700)
I was trying to continue the hash table loop, not the inner loop.  This
tended to work out, because we would have *just* freed the job struct.
Fixes some valgrind failures in fbo-depthtex.

Fixes: f597ac396640 ("vc4: Implement job shuffling")
src/gallium/drivers/vc4/vc4_job.c

index 1dab4bedd324f93106bb9fee106041419e6810d5..6a1d1a4cebfe512799130c17ac822e3e5afba5fb 100644 (file)
@@ -118,12 +118,17 @@ vc4_flush_jobs_reading_resource(struct vc4_context *vc4,
                 struct vc4_job *job = entry->data;
 
                 struct vc4_bo **referenced_bos = job->bo_pointers.base;
+                bool found = false;
                 for (int i = 0; i < cl_offset(&job->bo_handles) / 4; i++) {
                         if (referenced_bos[i] == rsc->bo) {
-                                vc4_job_submit(vc4, job);
-                                continue;
+                                found = true;
+                                break;
                         }
                 }
+                if (found) {
+                        vc4_job_submit(vc4, job);
+                        continue;
+                }
 
                 /* Also check for the Z/color buffers, since the references to
                  * those are only added immediately before submit.