From e952189443430a24fa5a9ebefd8c4c649f14670c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 18 Feb 2024 08:43:07 -0400 Subject: [PATCH] asahi: fix overread with samplers Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/decode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index c65a0a0f345..11e12d2f964 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -423,10 +423,11 @@ agxdecode_usc(const uint8_t *map, UNUSED uint64_t *link, UNUSED bool verbose, agx_unpack(agxdecode_dump_stream, map, USC_SAMPLER, temp); DUMP_UNPACKED(USC_SAMPLER, temp, "Sampler state\n"); - uint8_t buf[(AGX_SAMPLER_LENGTH + AGX_BORDER_LENGTH) * temp.count]; - uint8_t *samp = buf; + size_t stride = + AGX_SAMPLER_LENGTH + (extended_samplers ? AGX_BORDER_LENGTH : 0); + uint8_t *samp = alloca(stride * temp.count); - agxdecode_fetch_gpu_array(temp.buffer, buf); + agxdecode_fetch_gpu_mem(temp.buffer, stride * temp.count, samp); for (unsigned i = 0; i < temp.count; ++i) { DUMP_CL(SAMPLER, samp, "Sampler");