summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Vesely <jan.vesely@rutgers.edu>2018-05-18 11:39:15 -0400
committerJan Vesely <jan.vesely@rutgers.edu>2018-05-25 12:12:00 -0400
commitc1f2d9b900e30119bcf6f88c0d11a0dd620fd060 (patch)
treec0307cd6398788db1ea202814c593b1ff5b00a1e
parent52ef6fbaf1962dac2a8b75078c20d65da90cfe8d (diff)
downloadexternal_libdrm-c1f2d9b900e30119bcf6f88c0d11a0dd620fd060.tar.gz
external_libdrm-c1f2d9b900e30119bcf6f88c0d11a0dd620fd060.tar.bz2
external_libdrm-c1f2d9b900e30119bcf6f88c0d11a0dd620fd060.zip
amdgpu: Destroy fd_hash table when the last device is removed.
Fixes memory leak on module unload. Analogous to mesa commit of the same name. Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--amdgpu/amdgpu_device.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index e23dd3b36..34ac95b85 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -128,6 +128,10 @@ 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));
+ if (util_hash_table_count(fd_tab) == 0) {
+ util_hash_table_destroy(fd_tab);
+ fd_tab = NULL;
+ }
close(dev->fd);
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
close(dev->flink_fd);