radeonsi: fix a crash in gfx10_sh_query_get_result_resource

If tmp_buffer (in ssbo[1]) is NULL, setting the writable bit causes
the called function to access the NULL buffer.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16885>
This commit is contained in:
Marek Olšák 2022-06-03 17:38:09 -04:00 committed by Marge Bot
parent fc392ff104
commit 0f4f98ea50

View file

@ -403,9 +403,11 @@ static void gfx10_sh_query_get_result_resource(struct si_context *sctx, struct s
si_cp_wait_mem(sctx, &sctx->gfx_cs, va, 0x00000001, 0x00000001, 0);
}
/* ssbo[2] is either tmp_buffer or resource */
assert(ssbo[2].buffer);
si_launch_grid_internal_ssbos(sctx, &grid, sctx->sh_query_result_shader,
SI_OP_SYNC_PS_BEFORE | SI_OP_SYNC_AFTER, SI_COHERENCY_SHADER,
3, ssbo, 0x6);
3, ssbo, (1 << 2) | (ssbo[1].buffer ? 1 << 1 : 0));
if (qbuf == query->last)
break;