aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Vesely <[email protected]>2018-05-10 18:29:13 -0400
committerJuan A. Suarez Romero <[email protected]>2018-05-15 11:14:49 +0200
commit538022adf879c9682a9bdac75ec1a199a68b6a31 (patch)
tree58f41a5871275723ea30f0b01d3dd6dd79a50df7
parent478897779838154fca42beb297057016d403cb18 (diff)
winsys/amdgpu: Destroy dev_hash table when the last winsys is removed.
Fixes memory leak on module unload. CC: <[email protected]> Signed-off-by: Jan Vesely <[email protected]> Reviewed-by: Marek Olšák <[email protected]> (cherry picked from commit 58272c1ad771802a6f15a482ae552649e9085042)
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index ab91faf7cbc..e438241a378 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -220,8 +220,13 @@ static bool amdgpu_winsys_unref(struct radeon_winsys *rws)
simple_mtx_lock(&dev_tab_mutex);
destroy = pipe_reference(&ws->reference, NULL);
- if (destroy && dev_tab)
+ if (destroy && dev_tab) {
util_hash_table_remove(dev_tab, ws->dev);
+ if (util_hash_table_count(dev_tab) == 0) {
+ util_hash_table_destroy(dev_tab);
+ dev_tab = NULL;
+ }
+ }
simple_mtx_unlock(&dev_tab_mutex);
return destroy;