From 7c860f44b67e04d8616ccc40761ec6832c0e45f5 Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Wed, 27 Jun 2018 18:51:33 -0400 Subject: [PATCH] Fix a bug that fmm_init_process_apertures() returns incorrect value If opening drm render device fails (usually when the user is not a member of video group), fmm_init_process_apertures() still returns success, resulting in weird segfault in a later stage. Change-Id: Ifbde4481629988944ad7f384d59753c88e287fa9 Signed-off-by: Yong Zhao [ROCm/ROCR-Runtime commit: 77ec699460d088f5e4790cef2f21bfd79a478aa1] --- projects/rocr-runtime/src/fmm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/projects/rocr-runtime/src/fmm.c b/projects/rocr-runtime/src/fmm.c index 32c9b5b592..9aeca436af 100644 --- a/projects/rocr-runtime/src/fmm.c +++ b/projects/rocr-runtime/src/fmm.c @@ -1704,11 +1704,13 @@ HSAKMT_STATUS fmm_init_process_apertures(unsigned int NumNodes) /* Skip non-GPU nodes */ if (gpu_id != 0) { - gpu_mem[gpu_mem_count].drm_render_fd = - open_drm_render_device(props.DrmRenderMinor); - if (gpu_mem[gpu_mem_count].drm_render_fd <= 0) + int fd = open_drm_render_device(props.DrmRenderMinor); + if (fd <= 0) { + ret = HSAKMT_STATUS_ERROR; goto sysfs_parse_failed; + } + gpu_mem[gpu_mem_count].drm_render_fd = fd; gpu_mem[gpu_mem_count].gpu_id = gpu_id; gpu_mem[gpu_mem_count].local_mem_size = props.LocalMemSize; gpu_mem[gpu_mem_count].device_id = props.DeviceId;