[PATCH v2] drm/i915: ensure segment offset never exceeds allowed max

Andi Shyti andi.shyti at linux.intel.com
Fri Oct 25 09:06:43 UTC 2024


Hi Krzysztof,

> -	while (offset >= sg_dma_len(r.sgt.sgp) >> PAGE_SHIFT) {
> -		offset -= sg_dma_len(r.sgt.sgp) >> PAGE_SHIFT;
> -		r.sgt = __sgt_iter(__sg_next(r.sgt.sgp), use_dma(iobase));
> -		if (!r.sgt.sgp)
> -			return -EINVAL;
> +	if (r.sgt.curr + (offset << PAGE_SHIFT) < r.sgt.max) {
> +		while (offset >= sg_dma_len(r.sgt.sgp) >> PAGE_SHIFT) {
> +			offset -= sg_dma_len(r.sgt.sgp) >> PAGE_SHIFT;
> +			r.sgt = __sgt_iter(__sg_next(r.sgt.sgp), use_dma(iobase));
> +			if (!r.sgt.sgp)
> +				return -EINVAL;

As we discussed already this would hide the real issue to the
user, eventually add a GEM_WARN_ON(!r.sgt.sgp) here.

Andi


More information about the Intel-gfx mailing list