Mesa (master): v3dv: check dest bitsize in color blit

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 29 10:44:17 UTC 2021


Module: Mesa
Branch: master
Commit: 33f9b06b0e91d8d22217106700210f3bfa723275
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=33f9b06b0e91d8d22217106700210f3bfa723275

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Thu Apr 15 10:53:41 2021 +0200

v3dv: check dest bitsize in color blit

Otherwise, if src_bit_size > 0 and dst_bit_size == 0, we end up doing a
bad shift in `1 << (dst_bit_size - 1)`, as `dst_bit_size - 1` is a
negative value (in this case would be MAX_UINT32).

Fixes CID#1468134 "Bad bit shift operation (BAD_SHIFT)":
   "large_shift: In expression 1 << dst_bit_size - 1U, left shifting by
    more than 31 bits has undefined behavior. The shift amount,
    dst_bit_size - 1U, is 4294967295."

v2:
 - Use an assertion instead (Iago)

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10251>

---

 src/broadcom/vulkan/v3dv_meta_copy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/broadcom/vulkan/v3dv_meta_copy.c b/src/broadcom/vulkan/v3dv_meta_copy.c
index 56e5894f88e..cf8231995f6 100644
--- a/src/broadcom/vulkan/v3dv_meta_copy.c
+++ b/src/broadcom/vulkan/v3dv_meta_copy.c
@@ -4657,6 +4657,7 @@ get_color_blit_fs(struct v3dv_device *device,
          if (dst_bit_size >= src_bit_size)
             continue;
 
+         assert(dst_bit_size > 0);
          if (util_format_is_pure_uint(dst_pformat)) {
             nir_ssa_def *max = nir_imm_int(&b, (1 << dst_bit_size) - 1);
             c[i] = nir_umin(&b, c[i], max);



More information about the mesa-commit mailing list