Skip to content

Commit

Permalink
RDMA: Use rlimit helpers
Browse files Browse the repository at this point in the history
Make sure compiler won't do weird things with limits by using the
rlimit helpers added in 3e10e71 ("resource: add helpers for fetching
rlimits").  E.g. fetching them twice may return 2 different values
after writable limits are implemented.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Jiri Slaby authored and Roland Dreier committed Feb 11, 2010
1 parent 676ad58 commit ccbe9f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/infiniband/core/umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
down_write(&current->mm->mmap_sem);

locked = npages + current->mm->locked_vm;
lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;

if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
ret = -ENOMEM;
Expand Down
3 changes: 1 addition & 2 deletions drivers/infiniband/hw/ipath/ipath_user_pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ static int __get_user_pages(unsigned long start_page, size_t num_pages,
size_t got;
int ret;

lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
PAGE_SHIFT;
lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;

if (num_pages > lock_limit) {
ret = -ENOMEM;
Expand Down

0 comments on commit ccbe9f0

Please sign in to comment.