Fix double free on fork after hsaKmtCloseKFD

Child process hsaKmtOpenKFD() call must re-initialize global variables
copied from parent process. This includes close all file handles, free
dynamically malloc buf. Double free issue is because destroy_device_
debugging_memory() free the memory in parent process hsaKmtCloseKFD()
but don't reset it to null pointer. As a result, child process free it
again. kfd_fd is closed in parent process but don't reset to 0, so
child process close it again.

Fix: reset kfd_fd to 0 after close, reset is_device_debugged pointer to 0
after free



Change-Id: I421b3decbcaa4111298b8e599aa16940d851a58c
Signed-off-by: Philip Yang <Philip.Yang@amd.com>


[ROCm/ROCR-Runtime commit: 3501b2f40d]
此提交包含在:
Philip Yang
2017-10-26 10:54:15 -04:00
父節點 718134a369
當前提交 ac80bac82a
共有 2 個檔案被更改,包括 11 行新增3 行删除
+3 -1
查看文件
@@ -47,8 +47,10 @@ HSAKMT_STATUS init_device_debugging_memory(unsigned int NumNodes)
void destroy_device_debugging_memory(void)
{
if (is_device_debugged)
if (is_device_debugged) {
free(is_device_debugged);
is_device_debugged = NULL;
}
}
HSAKMT_STATUS HSAKMTAPI hsaKmtDbgRegister(HSAuint32 NodeId)