RDMA/odp: Fix missed unlock in non-blocking invalidate_start
authorJason Gunthorpe <jgg@mellanox.com>
Tue, 11 Jun 2019 16:09:51 +0000 (13:09 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:11:04 +0000 (09:11 +0200)
commit 7608bf40cf2480057ec0da31456cc428791c32ef upstream.

If invalidate_start returns with EAGAIN then the umem_rwsem needs to be
unlocked as no invalidate_end will be called.

Cc: <stable@vger.kernel.org>
Fixes: ca748c39ea3f ("RDMA/umem: Get rid of per_mm->notifier_count")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/core/umem_odp.c

index f962b5bbfa40e4268de37f99c78b6653895c9599..e4b13a32692a97dc9f87b88060bbf3eef9b1a619 100644 (file)
@@ -151,6 +151,7 @@ static int ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,
 {
        struct ib_ucontext_per_mm *per_mm =
                container_of(mn, struct ib_ucontext_per_mm, mn);
+       int rc;
 
        if (mmu_notifier_range_blockable(range))
                down_read(&per_mm->umem_rwsem);
@@ -167,11 +168,14 @@ static int ib_umem_notifier_invalidate_range_start(struct mmu_notifier *mn,
                return 0;
        }
 
-       return rbt_ib_umem_for_each_in_range(&per_mm->umem_tree, range->start,
-                                            range->end,
-                                            invalidate_range_start_trampoline,
-                                            mmu_notifier_range_blockable(range),
-                                            NULL);
+       rc = rbt_ib_umem_for_each_in_range(&per_mm->umem_tree, range->start,
+                                          range->end,
+                                          invalidate_range_start_trampoline,
+                                          mmu_notifier_range_blockable(range),
+                                          NULL);
+       if (rc)
+               up_read(&per_mm->umem_rwsem);
+       return rc;
 }
 
 static int invalidate_range_end_trampoline(struct ib_umem_odp *item, u64 start,