etnaviv: move pctx initialisation to avoid a null dereference
In case ctx->stream == NULL the fail label gets executed where pctx gets dereferenced - too bad pctx is NULL in that case. Caught by Coverity, reported to me by imirkin. Cc: "17.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
This commit is contained in:
parent
f709096d0e
commit
a0b16a0890
|
@ -267,16 +267,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||||
{
|
{
|
||||||
struct etna_context *ctx = CALLOC_STRUCT(etna_context);
|
struct etna_context *ctx = CALLOC_STRUCT(etna_context);
|
||||||
struct etna_screen *screen;
|
struct etna_screen *screen;
|
||||||
struct pipe_context *pctx = NULL;
|
struct pipe_context *pctx;
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
screen = etna_screen(pscreen);
|
|
||||||
ctx->stream = etna_cmd_stream_new(screen->pipe, 0x2000, &etna_cmd_stream_reset_notify, ctx);
|
|
||||||
if (ctx->stream == NULL)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
pctx = &ctx->base;
|
pctx = &ctx->base;
|
||||||
pctx->priv = ctx;
|
pctx->priv = ctx;
|
||||||
pctx->screen = pscreen;
|
pctx->screen = pscreen;
|
||||||
|
@ -285,6 +280,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||||
goto fail;
|
goto fail;
|
||||||
pctx->const_uploader = pctx->stream_uploader;
|
pctx->const_uploader = pctx->stream_uploader;
|
||||||
|
|
||||||
|
screen = etna_screen(pscreen);
|
||||||
|
ctx->stream = etna_cmd_stream_new(screen->pipe, 0x2000, &etna_cmd_stream_reset_notify, ctx);
|
||||||
|
if (ctx->stream == NULL)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
/* context ctxate setup */
|
/* context ctxate setup */
|
||||||
ctx->specs = screen->specs;
|
ctx->specs = screen->specs;
|
||||||
ctx->screen = screen;
|
ctx->screen = screen;
|
||||||
|
|
Loading…
Reference in New Issue