Mesa (master): etnaviv: fix memory leak when BO allocation fails
Lucas Stach
lynxeye at kemper.freedesktop.org
Thu Jun 29 09:36:24 UTC 2017
Module: Mesa
Branch: master
Commit: 4fb9f97047eb1e43c47cb7cacba27ccd20383eff
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4fb9f97047eb1e43c47cb7cacba27ccd20383eff
Author: Lucas Stach <l.stach at pengutronix.de>
Date: Fri Jun 9 18:20:56 2017 +0200
etnaviv: fix memory leak when BO allocation fails
The resource struct is already allocated at this point and should be
freed properly.
Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel at pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner at gmail.com>
Reviewed-by: Wladimir J. van der Laan <laanwj at gmail.com>
---
src/gallium/drivers/etnaviv/etnaviv_resource.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index dfd0870711..97e0a15597 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -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");
- return NULL;
+ goto free_rsc;
}
rsc->bo = bo;
@@ -223,6 +223,10 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout,
}
return &rsc->base;
+
+free_rsc:
+ FREE(rsc);
+ return NULL;
}
static struct pipe_resource *
More information about the mesa-commit
mailing list