mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 13:10:10 +01:00
anv: fix AHB leak upon exportable allocation
A successful AHardwareBuffer_allocate itself will increase a refcount on the newly allocated AHB. For the import case, the implementation must acquire a reference on the AHB. So if we layer the exportable allocation on top of AHB allocation and AHB import, we must release an AHB reference to avoid leak. Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10940>
This commit is contained in:
parent
f18c55708a
commit
2797c75426
2 changed files with 9 additions and 9 deletions
|
|
@ -437,8 +437,15 @@ anv_create_ahw_memory(VkDevice device_h,
|
|||
if (AHardwareBuffer_allocate(&desc, &ahw) != 0)
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
|
||||
mem->ahw = ahw;
|
||||
return VK_SUCCESS;
|
||||
const VkImportAndroidHardwareBufferInfoANDROID import_info = {
|
||||
.buffer = ahw,
|
||||
};
|
||||
result = anv_import_ahw_memory(device_h, mem, &import_info);
|
||||
|
||||
/* Release a reference to avoid leak for AHB allocation. */
|
||||
AHardwareBuffer_release(ahw);
|
||||
|
||||
return result;
|
||||
#else
|
||||
return VK_ERROR_EXTENSION_NOT_PRESENT;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3828,13 +3828,6 @@ VkResult anv_AllocateMemory(
|
|||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
const VkImportAndroidHardwareBufferInfoANDROID import_info = {
|
||||
.buffer = mem->ahw,
|
||||
};
|
||||
result = anv_import_ahw_memory(_device, mem, &import_info);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
goto success;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue