[Intel-gfx] [PATCH] drm/i915/selftests: fix subtraction overflow bug

Andi Shyti andi.shyti at linux.intel.com
Fri Jun 24 11:52:13 UTC 2022


Hi Andrzej,

On Fri, Jun 24, 2022 at 01:35:28PM +0200, Andrzej Hajda wrote:
> 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: e1c5f754067b59 ("drm/i915: Avoid overflow in computing pot_hole loop termination")
> Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3674
> Signed-off-by: Andrzej Hajda <andrzej.hajda at intel.com>
> ---
>  drivers/gpu/drm/i915/selftests/i915_gem_gtt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index 8633bec18fa75e..ab9f17fc85bcf2 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -742,7 +742,7 @@ static int pot_hole(struct i915_address_space *vm,
>  		u64 addr;
>  
>  		for (addr = round_up(hole_start + min_alignment, step) - min_alignment;
> -		     addr <= round_down(hole_end - (2 * min_alignment), step) - min_alignment;
> +		     hole_end > addr && hole_end - addr >= 2 * min_alignment;

Reviewed-by: Andi Shyti <andi.shyti at linux.intel.com>

Thanks,
Andi


More information about the Intel-gfx mailing list