Probably unlikely however ensure we don't leak a heap allocation
on the fail path.
V.2:
also fix missing 'amdgpu_device_deinitialize()' calls (Emil Velikov).
Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
ws = calloc(1, sizeof(struct radv_amdgpu_winsys));
if (!ws)
- return NULL;
+ 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 winsys_fail;
ws->debug_all_bos = getenv("RADV_DEBUG_ALL_BOS") ? true : false;
LIST_INITHEAD(&ws->global_bo_list);
radv_amdgpu_surface_init_functions(ws);
return &ws->base;
+
+winsys_fail:
+ free(ws);
fail:
+ amdgpu_device_deinitialize(dev);
return NULL;
}