v3dv: check dest bitsize in color blit
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Thu, 15 Apr 2021 08:53:41 +0000 (10:53 +0200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 29 Apr 2021 10:31:11 +0000 (10:31 +0000)
commit33f9b06b0e91d8d22217106700210f3bfa723275
tree81719f3f4790eeb9657d4fb0ecdac858e2f79d11
parentfd8d71ce41a3c51edb507fff927dee606a4ea5fa
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@igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10251>
src/broadcom/vulkan/v3dv_meta_copy.c