anv: avoid potential integer overflow

Coverity points out that we're using a 32bit type on the left side here,
so the entire operation is done as 32 bit instead of 64

CID: 1646960
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35114>
This commit is contained in:
Dylan Baker 2025-05-22 09:37:24 -07:00 committed by Marge Bot
parent 2a3cf70db8
commit ff5cb90880

View file

@ -134,7 +134,7 @@ anv_slab_bo_alloc(struct anv_device *device, const char *name, uint64_t requeste
const unsigned num_slab_allocator = ARRAY_SIZE(device->bo_slabs);
struct pb_slabs *last_slab = &device->bo_slabs[num_slab_allocator - 1];
const uint64_t max_slab_entry_size = 1 << (last_slab->min_order + last_slab->num_orders - 1);
const uint64_t max_slab_entry_size = BITFIELD64_BIT(last_slab->min_order + last_slab->num_orders - 1);
if (requested_size > max_slab_entry_size)
return NULL;