[Mesa-dev] [PATCH 2/3] etnaviv: move pctx initialisation to avoid a null dereference

Eric Engestrom eric.engestrom at imgtec.com
Thu Feb 9 10:59:33 UTC 2017


On Thursday, 2017-02-09 08:19:39 +0100, Christian Gmeiner wrote:
> 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.
> 
> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_context.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c
> index d767cd1..9cbbe2e 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_context.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c
> @@ -256,15 +256,15 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
>     if (ctx == NULL)
>        return NULL;
>  
> +   pctx = &ctx->base;

With this, you can also drop the `pctx = NULL` a couple lines above.

Series is:
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

Cheers,
  Eric

> +   pctx->priv = ctx;
> +   pctx->screen = pscreen;
> +
>     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;
> -
>     /* context ctxate setup */
>     ctx->specs = screen->specs;
>     ctx->screen = screen;
> -- 
> 2.7.4
> 


More information about the etnaviv mailing list