In cases where dma_addr is a 64-bit value its calculation is
still carried out using 32-bit arithmetic, which could
occassionally cause a truncation of values before they are
extended to 64 bits. Cast one of the operands to dma_addr_t,
so 64-bit arithmetic is used.

Cc: Danilo Krummrich <[email protected]>
Signed-off-by: Krzysztof Karas <[email protected]>
---

v6:
 * clarify commit message (Andi);

v5:
 * take this change into a separate patch (Jani);

 drivers/gpu/drm/drm_fb_dma_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_dma_helper.c 
b/drivers/gpu/drm/drm_fb_dma_helper.c
index 2b2513188001..c3b9e49bd755 100644
--- a/drivers/gpu/drm/drm_fb_dma_helper.c
+++ b/drivers/gpu/drm/drm_fb_dma_helper.c
@@ -104,8 +104,8 @@ dma_addr_t drm_fb_dma_get_gem_addr(struct drm_framebuffer 
*fb,
        block_start_y = (sample_y / block_h) * block_h;
        num_hblocks = sample_x / block_w;
 
-       dma_addr += fb->pitches[plane] * block_start_y;
-       dma_addr += block_size * num_hblocks;
+       dma_addr += (dma_addr_t)fb->pitches[plane] * block_start_y;
+       dma_addr += (dma_addr_t)block_size * num_hblocks;
 
        return dma_addr;
 }
-- 
2.34.1

Reply via email to