panfrost: fix off-by-one when exporting format modifiers
authorItalo Nicola <italonicola@collabora.com>
Tue, 24 Jan 2023 14:23:56 +0000 (14:23 +0000)
committerEric Engestrom <eric@engestrom.ch>
Thu, 26 Jan 2023 15:40:35 +0000 (15:40 +0000)
commit3a65dc4f7f430e158296821962cd8e0ab97a3783
treef8b9b352b5ffe609405524253d8c74c3c1ecd5c8
parent518487158abcf1486bcadc5c967b43176d968fda
panfrost: fix off-by-one when exporting format modifiers

`count` should not be incremented before the check, because it causes
the modifiers array to be filled starting from position 1 instead of 0.

This bug causes one less format modifier to be available than would
otherwise be expected, which could then lead to a dmabuf query failing
in situations where a supported modifier wouldn't be advertised.

It also causes garbage data to be advertised as a modifier in position 0
of the array, although this is not very likely to cause issues.

Fixes: 2a1217513 ("panfrost: Implement panfrost_query_dmabuf_modifiers")
Cc: mesa-stable
Signed-off-by: Italo Nicola <italonicola@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20879>
(cherry picked from commit 6c446377ff22d981191929de21cedecf519fe70f)
.pick_status.json
src/gallium/drivers/panfrost/pan_screen.c