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