Commit 712fa0f3 authored by Jan Vesely's avatar Jan Vesely
Browse files

amdgpu: Take a lock before removing devices from fd_tab hash table.



Close the file descriptors under lock as well.
v2: close fds after removing from hash table
Signed-off-by: Jan Vesely's avatarJan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 35615697
...@@ -126,6 +126,13 @@ static int amdgpu_get_auth(int fd, int *auth) ...@@ -126,6 +126,13 @@ static int amdgpu_get_auth(int fd, int *auth)
static void amdgpu_device_free_internal(amdgpu_device_handle dev) static void amdgpu_device_free_internal(amdgpu_device_handle dev)
{ {
pthread_mutex_lock(&fd_mutex);
util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
close(dev->fd);
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
close(dev->flink_fd);
pthread_mutex_unlock(&fd_mutex);
amdgpu_vamgr_deinit(&dev->vamgr_32); amdgpu_vamgr_deinit(&dev->vamgr_32);
amdgpu_vamgr_deinit(&dev->vamgr); amdgpu_vamgr_deinit(&dev->vamgr);
amdgpu_vamgr_deinit(&dev->vamgr_high_32); amdgpu_vamgr_deinit(&dev->vamgr_high_32);
...@@ -133,10 +140,6 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev) ...@@ -133,10 +140,6 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev)
util_hash_table_destroy(dev->bo_flink_names); util_hash_table_destroy(dev->bo_flink_names);
util_hash_table_destroy(dev->bo_handles); util_hash_table_destroy(dev->bo_handles);
pthread_mutex_destroy(&dev->bo_table_mutex); pthread_mutex_destroy(&dev->bo_table_mutex);
util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
close(dev->fd);
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
close(dev->flink_fd);
free(dev->marketing_name); free(dev->marketing_name);
free(dev); free(dev);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment