From 636ac989b2ef4ada8239a49521cf37be2fa81c0c Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Mon, 10 Feb 2014 18:29:43 +0000 Subject: [PATCH] vl/winsys_dri: cleanup vl_screen_create error path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Emil Velikov Reviewed-by: Jakob Bornecrantz Reviewed-by: Christian König --- src/gallium/auxiliary/vl/vl_winsys_dri.c | 32 ++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index fb4aaadd48a..5d83e5799da 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -330,7 +330,7 @@ vl_screen_create(Display *display, int screen) dri2_query_cookie = xcb_dri2_query_version (scrn->conn, XCB_DRI2_MAJOR_VERSION, XCB_DRI2_MINOR_VERSION); dri2_query = xcb_dri2_query_version_reply (scrn->conn, dri2_query_cookie, &error); if (dri2_query == NULL || error != NULL || dri2_query->minor_version < 2) - goto free_screen; + goto free_query; s = xcb_setup_roots_iterator(xcb_get_setup(scrn->conn)); while (screen--) @@ -353,48 +353,54 @@ vl_screen_create(Display *display, int screen) connect_cookie = xcb_dri2_connect_unchecked(scrn->conn, s.data->root, driverType); connect = xcb_dri2_connect_reply(scrn->conn, connect_cookie, NULL); if (connect == NULL || connect->driver_name_length + connect->device_name_length == 0) - goto free_screen; + goto free_connect; device_name_length = xcb_dri2_connect_device_name_length(connect); device_name = CALLOC(1, device_name_length + 1); + if (!device_name) + goto free_connect; memcpy(device_name, xcb_dri2_connect_device_name(connect), device_name_length); fd = open(device_name, O_RDWR); free(device_name); if (fd < 0) - goto free_screen; + goto free_connect; if (drmGetMagic(fd, &magic)) - goto free_screen; + goto free_connect; authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, s.data->root, magic); authenticate = xcb_dri2_authenticate_reply(scrn->conn, authenticate_cookie, NULL); if (authenticate == NULL || !authenticate->authenticated) - goto free_screen; + goto free_authenticate; scrn->base.pscreen = driver_descriptor.create_screen(fd); + if (!scrn->base.pscreen) - goto free_screen; + goto free_authenticate; scrn->base.pscreen->flush_frontbuffer = vl_dri2_flush_frontbuffer; vl_compositor_reset_dirty_area(&scrn->dirty_areas[0]); vl_compositor_reset_dirty_area(&scrn->dirty_areas[1]); - free(dri2_query); - free(connect); free(authenticate); + free(connect); + free(dri2_query); + free(error); return &scrn->base; -free_screen: - FREE(scrn); - - free(dri2_query); - free(connect); +free_authenticate: free(authenticate); +free_connect: + free(connect); +free_query: + free(dri2_query); free(error); +free_screen: + FREE(scrn); return NULL; } -- 2.30.2