diff options
author | Aleksander Morgado <[email protected]> | 2017-07-06 11:35:37 +0200 |
---|---|---|
committer | Christian Gmeiner <[email protected]> | 2017-07-06 21:06:25 +0200 |
commit | a6893a50c8ae5b68e4175366dac718ee9f6fa9d1 (patch) | |
tree | dfe893a0f2476a5053b83e7276e86e8c8518d081 | |
parent | c5d0dc7fa5566941a49ede8c83a0cfe0a33a3d7f (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]>
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_resource.c | 10 |
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 97e0a15597f..a709482c1b6 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c @@ -320,9 +320,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, " @@ -331,9 +331,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); |