summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorAleksander Morgado <[email protected]>2017-07-06 11:35:37 +0200
committerAndres Gomez <[email protected]>2017-07-12 19:32:09 +0300
commit914a26d549aa5f5e28fc6a45292c225e663aa644 (patch)
treeda099d83594991c733c649a644dbc33a8a694101 /src/gallium/drivers
parentc6e841667f27f7c97f80f9b447d22b1610372353 (diff)
etnaviv: don't dereference etna_resource pointer if allocation fails
The check for the pointer being non-NULL was being done too late. Signed-off-by: Aleksander Morgado <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]> (cherry picked from commit a6893a50c8ae5b68e4175366dac718ee9f6fa9d1)
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/etnaviv/etnaviv_resource.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index f3d73a8841e..2bb849a3dca 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -323,9 +323,9 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
struct winsys_handle *handle, unsigned usage)
{
struct etna_screen *screen = etna_screen(pscreen);
- struct etna_resource *rsc = CALLOC_STRUCT(etna_resource);
- struct etna_resource_level *level = &rsc->levels[0];
- struct pipe_resource *prsc = &rsc->base;
+ struct etna_resource *rsc;
+ struct etna_resource_level *level;
+ struct pipe_resource *prsc;
struct pipe_resource *ptiled = NULL;
DBG("target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, "
@@ -334,9 +334,13 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
tmpl->height0, tmpl->depth0, tmpl->array_size, tmpl->last_level,
tmpl->nr_samples, tmpl->usage, tmpl->bind, tmpl->flags);
+ rsc = CALLOC_STRUCT(etna_resource);
if (!rsc)
return NULL;
+ level = &rsc->levels[0];
+ prsc = &rsc->base;
+
*prsc = *tmpl;
pipe_reference_init(&prsc->reference, 1);