aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2016-06-01 15:04:13 -0500
committerRob Clark2016-07-20 18:42:21 -0500
commit19b82b9817b696cfe06d32340cb65231775b203b (patch)
tree3389581998f145e103907172ad3b4710fbccdb13 /freedreno
parent9e697c74991bd265a549bedfc7cd4a0267e234df (diff)
downloadexternal-libdrm-19b82b9817b696cfe06d32340cb65231775b203b.tar.gz
external-libdrm-19b82b9817b696cfe06d32340cb65231775b203b.tar.xz
external-libdrm-19b82b9817b696cfe06d32340cb65231775b203b.zip
freedreno: fix potential leak at free
If user has emit'd reloc's, and then resets or deletes the ring, we want to drop the ref's that the ring holds to the bo's to avoid a leak. Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno')
-rw-r--r--freedreno/freedreno_ringbuffer.c1
-rw-r--r--freedreno/msm/msm_ringbuffer.c12
2 files changed, 7 insertions, 6 deletions
diff --git a/freedreno/freedreno_ringbuffer.c b/freedreno/freedreno_ringbuffer.c
index ab5d31fc..34a06d83 100644
--- a/freedreno/freedreno_ringbuffer.c
+++ b/freedreno/freedreno_ringbuffer.c
@@ -57,6 +57,7 @@ fd_ringbuffer_new(struct fd_pipe *pipe, uint32_t size)
57 57
58void fd_ringbuffer_del(struct fd_ringbuffer *ring) 58void fd_ringbuffer_del(struct fd_ringbuffer *ring)
59{ 59{
60 fd_ringbuffer_reset(ring);
60 ring->funcs->destroy(ring); 61 ring->funcs->destroy(ring);
61} 62}
62 63
diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index b5a50def..32ed8b49 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -204,6 +204,12 @@ static void flush_reset(struct fd_ringbuffer *ring)
204 struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); 204 struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
205 unsigned i; 205 unsigned i;
206 206
207 for (i = 0; i < msm_ring->nr_bos; i++) {
208 struct msm_bo *msm_bo = to_msm_bo(msm_ring->bos[i]);
209 msm_bo->current_ring = NULL;
210 fd_bo_del(&msm_bo->base);
211 }
212
207 /* for each of the cmd buffers, clear their reloc's: */ 213 /* for each of the cmd buffers, clear their reloc's: */
208 for (i = 0; i < msm_ring->submit.nr_cmds; i++) { 214 for (i = 0; i < msm_ring->submit.nr_cmds; i++) {
209 struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]); 215 struct msm_ringbuffer *target_ring = to_msm_ringbuffer(msm_ring->rings[i]);
@@ -280,12 +286,6 @@ static int msm_ringbuffer_flush(struct fd_ringbuffer *ring, uint32_t *last_start
280 } 286 }
281 } 287 }
282 288
283 for (i = 0; i < msm_ring->nr_bos; i++) {
284 struct msm_bo *msm_bo = to_msm_bo(msm_ring->bos[i]);
285 msm_bo->current_ring = NULL;
286 fd_bo_del(&msm_bo->base);
287 }
288
289 flush_reset(ring); 289 flush_reset(ring);
290 290
291 return ret; 291 return ret;