[Mesa-dev] [PATCH 2/3] etnaviv: move pctx initialisation to avoid a null dereference
Christian Gmeiner
christian.gmeiner at gmail.com
Thu Feb 9 16:12:21 UTC 2017
Hi Eric
2017-02-09 11:59 GMT+01:00 Eric Engestrom <eric.engestrom at imgtec.com>:
> 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.
>
Will change it locally before pushing - thanks!
> 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
>>
greets
--
Christian Gmeiner, MSc
https://www.youtube.com/user/AloryOFFICIAL
https://soundcloud.com/christian-gmeiner
More information about the mesa-dev
mailing list