OSDN Git Service

RDMA/umem: minor bug fix in error handling path
authorJohn Hubbard <jhubbard@nvidia.com>
Mon, 4 Mar 2019 19:46:45 +0000 (11:46 -0800)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 4 Mar 2019 20:41:31 +0000 (16:41 -0400)
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 <jhubbard@nvidia.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Acked-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/umem_odp.c

index 6013cf0..577f1b1 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/vmalloc.h>
 #include <linux/hugetlb.h>
 #include <linux/interval_tree_generic.h>
+#include <linux/pagemap.h>
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_umem.h>
@@ -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;
                }
        }