mesa: fix misaligned pointer returned by dlist_alloc
authorCharmaine Lee <charmainel@vmware.com>
Wed, 2 Feb 2022 23:12:12 +0000 (15:12 -0800)
committerMarge Bot <emma+marge@anholt.net>
Sat, 5 Feb 2022 22:45:01 +0000 (22:45 +0000)
commit945a1e0b8cd57403c6a0cbf9b2fec112f233075e
tree2d4cdc873fc9de4b5501be541e8aa26f5d01c314
parent9230b28533682fe3126ec5328aba31f16f63864b
mesa: fix misaligned pointer returned by dlist_alloc

In cases where the to-be-allocated node size with padding exceeds BLOCK_SIZE
but without padding doesn't, a new block is not created and no padding is done
to the previous instruction, causing a misaligned pointer to be returned.

v2: Per Ilia Mirkin's suggestion, remove the extra condition in the first
    if statement, let it unconditionally pad the last instruction if needed.
    The updated currentPos will then be taken into account in the
    block size checking.

This fixes crash seen with lightsmark and Optuma apitraces

Fixes:  05605d7f537c4 (' mesa: remove display list OPCODE_NOP')

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Neha Bhende <bhenden@vmware.com>
Tested-by: Neha Bhende <bhenden@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14871>
src/mesa/main/dlist.c