lima: fix bo submit memory leak
authorErico Nunes <nunes.erico@gmail.com>
Mon, 28 Oct 2019 19:02:38 +0000 (20:02 +0100)
committerErico Nunes <nunes.erico@gmail.com>
Thu, 7 Nov 2019 23:03:01 +0000 (23:03 +0000)
Fix memory leak on allocation for lima submit, reported by valgrind.

128 bytes in 1 blocks are definitely lost in loss record 38 of 84
   at 0x484A6E8: realloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so)
   by 0x58689C7: util_dynarray_ensure_cap (u_dynarray.h:91)
   by 0x5868BBB: util_dynarray_grow_bytes (u_dynarray.h:139)
   by 0x5868BBB: lima_submit_add_bo (lima_submit.c:113)
   by 0x585D7D3: lima_ctx_buff_va (lima_context.c:57)
   by 0x586378F: lima_pack_plbu_cmd (lima_draw.c:802)
   by 0x586378F: lima_draw_vbo (lima_draw.c:1351)
   by 0x5406A2F: u_vbuf_draw_vbo (u_vbuf.c:1184)
   by 0x55D0A57: st_draw_vbo (st_draw.c:268)
   by 0x55576CB: _mesa_draw_arrays (draw.c:374)
   by 0x55576CB: _mesa_draw_arrays (draw.c:351)
   by 0x43610B: Mesh::render_vbo() (mesh.cpp:583)
   by 0x415DBB: SceneBuild::draw() (scene-build.cpp:242)
   by 0x41131B: MainLoop::draw() (main-loop.cpp:133)
   by 0x411947: MainLoop::step() (main-loop.cpp:108)

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
src/gallium/drivers/lima/lima_submit.c

index acc73d0..ff9a4a1 100644 (file)
@@ -78,6 +78,7 @@ struct lima_submit *lima_submit_create(struct lima_context *ctx, uint32_t pipe)
       goto err_out1;
 
    util_dynarray_init(&s->gem_bos, s);
+   util_dynarray_init(&s->bos, s);
 
    return s;