Skip to content

Commit ab3edc6

Browse files
ahajdarodrigovivi
authored andcommitted
drm/i915/selftests: fix subtraction overflow bug
On some machines hole_end can be small enough to cause subtraction overflow. On the other side (addr + 2 * min_alignment) can overflow in case of mock tests. This patch should handle both cases. Fixes: e1c5f75 ("drm/i915: Avoid overflow in computing pot_hole loop termination") Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3674 Signed-off-by: Andrzej Hajda <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Andi Shyti <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent c877bed commit ab3edc6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/i915/selftests/i915_gem_gtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ static int pot_hole(struct i915_address_space *vm,
742742
u64 addr;
743743

744744
for (addr = round_up(hole_start + min_alignment, step) - min_alignment;
745-
addr <= round_down(hole_end - (2 * min_alignment), step) - min_alignment;
745+
hole_end > addr && hole_end - addr >= 2 * min_alignment;
746746
addr += step) {
747747
err = i915_vma_pin(vma, 0, 0, addr | flags);
748748
if (err) {

0 commit comments

Comments
 (0)