diff options
author | Christian Gmeiner <[email protected]> | 2017-02-08 13:07:25 +0100 |
---|---|---|
committer | Christian Gmeiner <[email protected]> | 2017-02-21 21:14:27 +0100 |
commit | a0b16a08905d68da07668a42eeb464b4f30bf3e5 (patch) | |
tree | 4108148247183a62c45c3a9ea52c37395b78107b /src/gallium/drivers | |
parent | f709096d0e34c3f6c9b3e45683b301b9d97a0d1a (diff) |
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" <[email protected]>
Signed-off-by: Christian Gmeiner <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 62297a05047..5566e0ed38e 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -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_screen *screen; - struct pipe_context *pctx = NULL; + struct pipe_context *pctx; if (ctx == 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->priv = ctx; pctx->screen = pscreen; @@ -285,6 +280,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) goto fail; 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 */ ctx->specs = screen->specs; ctx->screen = screen; |