From cc530255bb25c7ba0675a4bb015e8871403c0eea Mon Sep 17 00:00:00 2001 From: Rajnesh Kanwal Date: Sun, 25 Sep 2022 20:11:53 +0100 Subject: [PATCH] pvr: Fix Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) errors. Fixes: CID 1503255, 1503258, 1503265, 1503268, 1504078, 1507509. Signed-off-by: Rajnesh Kanwal Reviewed-by: Frank Binns Reviewed-by: Karmjit Mahil Part-of: --- src/imagination/vulkan/pvr_job_render.c | 8 ++++---- src/imagination/vulkan/pvr_query.c | 2 +- src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/imagination/vulkan/pvr_job_render.c b/src/imagination/vulkan/pvr_job_render.c index 5b6458e..1526a4d 100644 --- a/src/imagination/vulkan/pvr_job_render.c +++ b/src/imagination/vulkan/pvr_job_render.c @@ -370,12 +370,12 @@ pvr_rt_get_isp_region_size(struct pvr_device *device, { const struct pvr_device_info *dev_info = &device->pdevice->dev_info; uint64_t rgn_size = - mtile_info->tiles_per_mtile_x * mtile_info->tiles_per_mtile_y; + (uint64_t)mtile_info->tiles_per_mtile_x * mtile_info->tiles_per_mtile_y; if (PVR_HAS_FEATURE(dev_info, simple_internal_parameter_format)) { uint32_t version; - rgn_size *= mtile_info->mtiles_x * mtile_info->mtiles_y; + rgn_size *= (uint64_t)mtile_info->mtiles_x * mtile_info->mtiles_y; if (PVR_FEATURE_VALUE(dev_info, simple_parameter_format_version, @@ -476,7 +476,7 @@ pvr_rt_get_tail_ptr_stride_size(const struct pvr_device *device, max_num_mtiles = MAX2(util_next_power_of_two64(num_mtiles_x), util_next_power_of_two64(num_mtiles_y)); - size = max_num_mtiles * max_num_mtiles; + size = (uint64_t)max_num_mtiles * max_num_mtiles; if (PVR_FEATURE_VALUE(&device->pdevice->dev_info, simple_parameter_format_version, @@ -573,7 +573,7 @@ static void pvr_rt_get_region_headers_stride_size( { const struct pvr_device_info *dev_info = &device->pdevice->dev_info; const uint32_t rgn_header_size = rogue_get_region_header_size(dev_info); - uint32_t rgn_headers_size; + uint64_t rgn_headers_size; uint32_t num_tiles_x; uint32_t num_tiles_y; uint32_t group_size; diff --git a/src/imagination/vulkan/pvr_query.c b/src/imagination/vulkan/pvr_query.c index ecfb07b..5776788 100644 --- a/src/imagination/vulkan/pvr_query.c +++ b/src/imagination/vulkan/pvr_query.c @@ -69,7 +69,7 @@ VkResult pvr_CreateQueryPool(VkDevice _device, /* Each Phantom writes to a separate offset within the vis test heap so * allocate space for the total number of Phantoms. */ - alloc_size = pool->result_stride * core_count; + alloc_size = (uint64_t)pool->result_stride * core_count; result = pvr_bo_alloc(device, device->heaps.vis_test_heap, diff --git a/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c b/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c index 5da06d5..61d478a 100644 --- a/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c +++ b/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.c @@ -417,7 +417,7 @@ static inline uint64_t pvr_srv_get_total_reserved_partition_size( 0); } - return max_partitions * 1024U; + return (uint64_t)max_partitions * 1024U; } static inline uint64_t -- 2.7.4