pan/cs: Make sure we don't overflow the chunk capacity

assert that a block is no bigger than a chunk allocated by
::alloc_buffer().

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31205>
This commit is contained in:
Boris Brezillon
2024-09-15 15:48:38 +02:00
committed by Marge Bot
parent bdd1335e4f
commit df1088e16f

View File

@@ -452,6 +452,9 @@ cs_alloc_ins(struct cs_builder *b, uint32_t num_instrs)
}
}
/* Make sure the instruction sequence fits in a single chunk. */
assert(b->cur_chunk.buffer.capacity >= num_instrs);
/* If the current chunk runs out of space, allocate a new one and jump to it.
* We actually do this a few instructions before running out, because the
* sequence to jump to a new queue takes multiple instructions.