OSDN Git Service

amdgpu: Destroy fd_hash table when the last device is removed.
authorJan Vesely <jan.vesely@rutgers.edu>
Fri, 18 May 2018 15:39:15 +0000 (11:39 -0400)
committerJan Vesely <jan.vesely@rutgers.edu>
Fri, 25 May 2018 16:12:00 +0000 (12:12 -0400)
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>
amdgpu/amdgpu_device.c

index e23dd3b..34ac95b 100644 (file)
@@ -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);