[Mesa-dev] [PATCH 03/12] winsys/amdgpu: clean up error paths in amdgpu_winsys_create

Nicolai Hähnle nhaehnle at gmail.com
Fri Sep 9 17:34:05 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

No need to call pb_cache_deinit, because the cache hasn't been initialized
at that point.
---
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 33aa492..521a78a 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -520,31 +520,29 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create)
    /* Lookup a winsys if we have already created one for this device. */
    ws = util_hash_table_get(dev_tab, dev);
    if (ws) {
       pipe_reference(NULL, &ws->reference);
       pipe_mutex_unlock(dev_tab_mutex);
       return &ws->base;
    }
 
    /* Create a new winsys. */
    ws = CALLOC_STRUCT(amdgpu_winsys);
-   if (!ws) {
-      pipe_mutex_unlock(dev_tab_mutex);
-      return NULL;
-   }
+   if (!ws)
+      goto fail;
 
    ws->dev = dev;
    ws->info.drm_major = drm_major;
    ws->info.drm_minor = drm_minor;
 
    if (!do_winsys_init(ws, fd))
-      goto fail;
+      goto fail_alloc;
 
    /* Create managers. */
    pb_cache_init(&ws->bo_cache, 500000, ws->check_vm ? 1.0f : 2.0f, 0,
                  (ws->info.vram_size + ws->info.gart_size) / 8,
                  amdgpu_bo_destroy, amdgpu_bo_can_reclaim);
 
    /* init reference */
    pipe_reference_init(&ws->reference, 1);
 
    /* Set functions. */
@@ -580,16 +578,16 @@ amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create)
 
    util_hash_table_set(dev_tab, dev, ws);
 
    /* We must unlock the mutex once the winsys is fully initialized, so that
     * other threads attempting to create the winsys from the same fd will
     * get a fully initialized winsys and not just half-way initialized. */
    pipe_mutex_unlock(dev_tab_mutex);
 
    return &ws->base;
 
+fail_alloc:
+   FREE(ws);
 fail:
    pipe_mutex_unlock(dev_tab_mutex);
-   pb_cache_deinit(&ws->bo_cache);
-   FREE(ws);
    return NULL;
 }
-- 
2.7.4



More information about the mesa-dev mailing list