Skip to content

Commit

Permalink
drivers/IB,qib: Fix pinned/locked limit check in qib_get_user_pages()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Davidlohr Bueso authored and Jason Gunthorpe committed Feb 20, 2019
1 parent d0e02bf commit ec95e0f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/qib/qib_user_pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit ec95e0f

Please sign in to comment.