From 75a3e6a3c129cddcc683538d8702c6ef998ec589 Mon Sep 17 00:00:00 2001 From: John Hubbard Date: Mon, 4 Mar 2019 11:46:45 -0800 Subject: RDMA/umem: minor bug fix in error handling path 1. Bug fix: fix an off by one error in the code that cleans up if it fails to dma-map a page, after having done a get_user_pages_remote() on a range of pages. 2. Refinement: for that same cleanup code, release_pages() is better than put_page() in a loop. Signed-off-by: John Hubbard Signed-off-by: Ira Weiny Reviewed-by: Ira Weiny Acked-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/umem_odp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/infiniband/core/umem_odp.c') diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c index 6013cf0b8f4f..577f1b12bff4 100644 --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -685,9 +686,11 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, mutex_unlock(&umem_odp->umem_mutex); if (ret < 0) { - /* Release left over pages when handling errors. */ - for (++j; j < npages; ++j) - put_page(local_page_list[j]); + /* + * Release pages, starting at the the first page + * that experienced an error. + */ + release_pages(&local_page_list[j], npages - j); break; } } -- cgit v1.2.3-59-g8ed1b