winsys/sw: Fix error paths
authorJakob Bornecrantz <wallbraker@gmail.com>
Sat, 10 Apr 2010 11:41:22 +0000 (13:41 +0200)
committerJakob Bornecrantz <wallbraker@gmail.com>
Sun, 11 Apr 2010 23:50:52 +0000 (01:50 +0200)
src/gallium/winsys/sw/drm/sw_drm_api.c
src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c

index eb81d26a5939fb1ee74ea2fcd113788f039cdb11..2ccde610e606eed9facdc9c49135ff52449b3708 100644 (file)
@@ -65,8 +65,12 @@ sw_drm_create_screen(struct drm_api *_api, int drmFD,
    struct pipe_screen *screen;
 
    screen = api->create_screen(api, drmFD, arg);
+   if (!screen)
+      return NULL;
 
    sww = wrapper_sw_winsys_warp_pipe_screen(screen);
+   if (!sww)
+      return NULL;
 
    return softpipe_create_screen(sww);
 }
@@ -86,7 +90,10 @@ sw_drm_api_create(struct drm_api *api)
 {
    struct sw_drm_api *swapi = CALLOC_STRUCT(sw_drm_api);
 
-   swapi->base.name = "sw";
+   if (!swapi)
+      return api;
+
+   swapi->base.name = api->name;
    swapi->base.driver_name = api->driver_name;
    swapi->base.create_screen = sw_drm_create_screen;
    swapi->base.destroy = sw_drm_destroy;
index 9a68d9faff6f8f0258658605d9fc58b65433e3f7..d4d4270eb864ab91b9522715de823e8218c77dc4 100644 (file)
@@ -262,6 +262,9 @@ wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen)
 {
    struct wrapper_sw_winsys *wsw = CALLOC_STRUCT(wrapper_sw_winsys);
 
+   if (!wsw)
+      goto err;
+
    wsw->base.displaytarget_create = wsw_dt_create;
    wsw->base.displaytarget_from_handle = wsw_dt_from_handle;
    wsw->base.displaytarget_map = wsw_dt_map;
@@ -272,11 +275,12 @@ wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen)
    wsw->screen = screen;
    wsw->pipe = screen->context_create(screen, NULL);
    if (!wsw->pipe)
-      goto err;
+      goto err_free;
 
    return &wsw->base;
 
-err:
+err_free:
    FREE(wsw);
+err:
    return NULL;
 }