summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDavidlohr Bueso <dave@stgolabs.net>2019-02-16 13:15:52 +0100
committerJason Gunthorpe <jgg@mellanox.com>2019-02-20 22:42:41 +0100
commitec95e0fa21628ed25f12187fb1067b8b10ad7c9a (patch)
tree8bb2c7af451c445d3f72ec7994c91de477db4747 /drivers/infiniband
parentRDMA/core: Verify that memory window type is legal (diff)
downloadlinux-ec95e0fa21628ed25f12187fb1067b8b10ad7c9a.tar.xz
linux-ec95e0fa21628ed25f12187fb1067b8b10ad7c9a.zip
drivers/IB,qib: Fix pinned/locked limit check in qib_get_user_pages()
The current check does not take into account the previous value of pinned_vm; thus it is quite bogus as is. Fix this by checking the new value after the (optimistic) atomic inc. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/qib/qib_user_pages.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/qib/qib_user_pages.c b/drivers/infiniband/hw/qib/qib_user_pages.c
index ef8bcf366ddc..123ca8f64f75 100644
--- a/drivers/infiniband/hw/qib/qib_user_pages.c
+++ b/drivers/infiniband/hw/qib/qib_user_pages.c
@@ -107,7 +107,7 @@ int qib_get_user_pages(unsigned long start_page, size_t num_pages,
lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
locked = atomic64_add_return(num_pages, &current->mm->pinned_vm);
- if (num_pages > lock_limit && !capable(CAP_IPC_LOCK)) {
+ if (locked > lock_limit && !capable(CAP_IPC_LOCK)) {
ret = -ENOMEM;
goto bail;
}