diff options
author | Serge Martin <[email protected]> | 2015-12-06 15:32:17 +0100 |
---|---|---|
committer | Rob Clark <[email protected]> | 2015-12-09 17:32:41 -0500 |
commit | 2b930327e871bb3307c37c919a449f860f30ae50 (patch) | |
tree | 0c860620e3ef30ae349ec3ef3dde12338c4aad0d /src | |
parent | 0149e7a944e65a0c7c6f7465ecf7103171943379 (diff) |
freedreno: little clean up in fd_create_surface
in order to avoid returing invalid adress if CALLOC_STRUCT return NULL.
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_surface.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_surface.c b/src/gallium/drivers/freedreno/freedreno_surface.c index 70c44eb79c3..90433934345 100644 --- a/src/gallium/drivers/freedreno/freedreno_surface.c +++ b/src/gallium/drivers/freedreno/freedreno_surface.c @@ -41,27 +41,28 @@ fd_create_surface(struct pipe_context *pctx, // struct fd_resource* tex = fd_resource(ptex); struct fd_surface* surface = CALLOC_STRUCT(fd_surface); + if (!surface) + return NULL; + debug_assert(ptex->target != PIPE_BUFFER); debug_assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer); - if (surface) { - struct pipe_surface *psurf = &surface->base; - unsigned level = surf_tmpl->u.tex.level; + struct pipe_surface *psurf = &surface->base; + unsigned level = surf_tmpl->u.tex.level; - pipe_reference_init(&psurf->reference, 1); - pipe_resource_reference(&psurf->texture, ptex); + pipe_reference_init(&psurf->reference, 1); + pipe_resource_reference(&psurf->texture, ptex); - psurf->context = pctx; - psurf->format = surf_tmpl->format; - psurf->width = u_minify(ptex->width0, level); - psurf->height = u_minify(ptex->height0, level); - psurf->u.tex.level = level; - psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer; - psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer; + psurf->context = pctx; + psurf->format = surf_tmpl->format; + psurf->width = u_minify(ptex->width0, level); + psurf->height = u_minify(ptex->height0, level); + psurf->u.tex.level = level; + psurf->u.tex.first_layer = surf_tmpl->u.tex.first_layer; + psurf->u.tex.last_layer = surf_tmpl->u.tex.last_layer; - // TODO - DBG("TODO: %ux%u", psurf->width, psurf->height); - } + // TODO + DBG("TODO: %ux%u", psurf->width, psurf->height); return &surface->base; } |