[Bug 108381] amdgpu_bo_import and amdgpu_bo_free are not paired which leaks amdgpu_bo

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Oct 16 05:11:55 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=108381

            Bug ID: 108381
           Summary: amdgpu_bo_import and amdgpu_bo_free are not paired
                    which leaks amdgpu_bo
           Product: Mesa
           Version: 18.2
          Hardware: All
                OS: Linux (All)
            Status: NEW
          Severity: major
          Priority: medium
         Component: Drivers/Gallium/radeonsi
          Assignee: dri-devel at lists.freedesktop.org
          Reporter: zhangyong at lbesec.com
        QA Contact: dri-devel at lists.freedesktop.org

Created attachment 142039
  --> https://bugs.freedesktop.org/attachment.cgi?id=142039&action=edit
sample code to reproduce the issue

amdgpu_bo is reference counted, libdrm expects the number of calls to
amdgpu_bo_import must be equal to amdgpu_bo_free.

When importing prime fd into mesa, amdgpu_bo_from_handle will be called, which
calls amdgpu_bo_import to get the unique handle (which in fact is a pointer to
amdgpu_bo), then wrapped into amdgpu_winsys_bo object.

The problem is amdgpu_winsys_bo is also reference counted, if one tries to
import the same prime fd for multiple times, amdgpu_bo_import will be called
for multiple times, but only one amdgpu_winsys_bo will be created, so
amdgpu_bo_free will be called for only once, eventually leaks memory.

I have attached a sample code to reproduce this issue.

a possible solution is to call amdgpu_bo_free after amdgpu_bo_import if
result.buf_handle can be found in ws->bo_export_table, which will balance the
number of calls to amdgpu_bo_import and amdgpu_bo_free.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20181016/76bf7343/attachment.html>


More information about the dri-devel mailing list