Mesa (master): isl: use 64bit arithmetic to compute size

Lionel Landwerlin llandwerlin at kemper.freedesktop.org
Thu Jul 13 21:51:09 UTC 2017


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

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Thu Jul 13 15:37:43 2017 +0100

isl: use 64bit arithmetic to compute size

If we allow the size to be more than 2^32, then we should compute it
in 64bit arithmetic otherwise we might run into overflow issues.

CID: 1412892, 1412891
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>

---

 src/intel/isl/isl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
index ba56d86c17..1026fe9495 100644
--- a/src/intel/isl/isl.c
+++ b/src/intel/isl/isl.c
@@ -1469,7 +1469,7 @@ isl_surf_init_s(const struct isl_device *dev,
    uint32_t base_alignment;
    uint64_t size;
    if (tiling == ISL_TILING_LINEAR) {
-      size = row_pitch * padded_h_el + pad_bytes;
+      size = (uint64_t) row_pitch * padded_h_el + pad_bytes;
 
       /* From the Broadwell PRM Vol 2d, RENDER_SURFACE_STATE::SurfaceBaseAddress:
        *
@@ -1494,7 +1494,7 @@ isl_surf_init_s(const struct isl_device *dev,
       const uint32_t total_h_tl =
          isl_align_div(padded_h_el, tile_info.logical_extent_el.height);
 
-      size = total_h_tl * tile_info.phys_extent_B.height * row_pitch;
+      size = (uint64_t) total_h_tl * tile_info.phys_extent_B.height * row_pitch;
 
       const uint32_t tile_size = tile_info.phys_extent_B.width *
                                  tile_info.phys_extent_B.height;




More information about the mesa-commit mailing list