etnaviv: fix memory leak when BO allocation fails
authorLucas Stach <l.stach@pengutronix.de>
Fri, 9 Jun 2017 16:20:56 +0000 (18:20 +0200)
committerLucas Stach <l.stach@pengutronix.de>
Thu, 29 Jun 2017 09:34:50 +0000 (11:34 +0200)
The resource struct is already allocated at this point and should be
freed properly.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Wladimir J. van der Laan <laanwj@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_resource.c

index dfd0870711932bbff817cb6a11125d5c3bb73674..97e0a15597fa4b8a43ba185c6ec234dcb17190cc 100644 (file)
@@ -208,7 +208,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
    struct etna_bo *bo = etna_bo_new(screen->dev, size, flags);
    if (unlikely(bo == NULL)) {
       BUG("Problem allocating video memory for resource");
    struct etna_bo *bo = etna_bo_new(screen->dev, size, flags);
    if (unlikely(bo == NULL)) {
       BUG("Problem allocating video memory for resource");
-      return NULL;
+      goto free_rsc;
    }
 
    rsc->bo = bo;
    }
 
    rsc->bo = bo;
@@ -223,6 +223,10 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
    }
 
    return &rsc->base;
    }
 
    return &rsc->base;
+
+free_rsc:
+   FREE(rsc);
+   return NULL;
 }
 
 static struct pipe_resource *
 }
 
 static struct pipe_resource *