r600g: Fixed a bo leak in r600_texture_from_handle().
authorTilman Sauerbeck <tilman@code-monkey.de>
Thu, 9 Sep 2010 12:03:46 +0000 (14:03 +0200)
committerTilman Sauerbeck <tilman@code-monkey.de>
Fri, 10 Sep 2010 11:09:33 +0000 (13:09 +0200)
We would leak bo if the argument check failed.

Signed-off-by: Tilman Sauerbeck <tilman@code-monkey.de>
src/gallium/drivers/r600/r600_texture.c

index dec616bce88533d4a37709d8299c658fcdc368c2..37907ef0e9a5af2416d52bc376c221547aa2100d 100644 (file)
@@ -199,11 +199,6 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
        struct r600_resource *resource;
        struct radeon_bo *bo = NULL;
 
-       bo = radeon_bo(rw, whandle->handle, 0, 0, NULL);
-       if (bo == NULL) {
-               return NULL;
-       }
-
        /* Support only 2D textures without mipmaps */
        if ((templ->target != PIPE_TEXTURE_2D && templ->target != PIPE_TEXTURE_RECT) ||
              templ->depth0 != 1 || templ->last_level != 0)
@@ -213,6 +208,12 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
        if (rtex == NULL)
                return NULL;
 
+       bo = radeon_bo(rw, whandle->handle, 0, 0, NULL);
+       if (bo == NULL) {
+               FREE(rtex);
+               return NULL;
+       }
+
        resource = &rtex->resource;
        resource->base.b = *templ;
        resource->base.vtbl = &r600_texture_vtbl;