From: John Hubbard Date: Wed, 6 Mar 2019 02:00:22 +0000 (-0800) Subject: RDMA/umem: Revert broken 'off by one' fix X-Git-Tag: v5.4-rc1~1451^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c507d8f846f0158babcc99fc235f17fc79cc2f4;p=platform%2Fkernel%2Flinux-rpi.git RDMA/umem: Revert broken 'off by one' fix The previous attempted bug fix overlooked the fact that ib_umem_odp_map_dma_single_page() was doing a put_page() upon hitting an error. So there was not really a bug there. Therefore, this reverts the off-by-one change, but keeps the change to use release_pages() in the error path. Fixes: 75a3e6a3c129 ("RDMA/umem: minor bug fix in error handling path") Suggested-by: Artemy Kovalyov Signed-off-by: John Hubbard Signed-off-by: Jason Gunthorpe --- diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c index 577f1b1..e6ec79a 100644 --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c @@ -687,10 +687,13 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, if (ret < 0) { /* - * Release pages, starting at the the first page - * that experienced an error. + * Release pages, remembering that the first page + * to hit an error was already released by + * ib_umem_odp_map_dma_single_page(). */ - release_pages(&local_page_list[j], npages - j); + if (npages - (j + 1) > 0) + release_pages(&local_page_list[j+1], + npages - (j + 1)); break; } }