From: Alyssa Rosenzweig Date: Tue, 8 Oct 2019 02:42:35 +0000 (-0400) Subject: pan/midgard: Fix memory corruption in register spilling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d914ebe818b47faa7ec778108be767c55b26c20;p=mesa.git pan/midgard: Fix memory corruption in register spilling Essentially an off-by-one error ... bit of an edge case, but seems to occur in some glamor shaders. Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 5d49f7f79f1..3a3a4f93448 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -531,11 +531,11 @@ mir_insert_instruction_after_scheduled( midgard_bundle *bundles = (midgard_bundle *) block->bundles.data; memmove(bundles + after + 2, bundles + after + 1, (count - after - 1) * sizeof(midgard_bundle)); - midgard_bundle *after_bundle_1 = bundles + after + 2; + midgard_bundle *after_bundle = bundles + after; midgard_bundle new = mir_bundle_for_op(ctx, ins); memcpy(bundles + after + 1, &new, sizeof(new)); - list_addtail(&new.instructions[0]->link, &after_bundle_1->instructions[0]->link); + list_addtail(&new.instructions[0]->link, &after_bundle->instructions[after_bundle->instruction_count - 1]->link); } /* Flip the first-two arguments of a (binary) op. Currently ALU