aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hugetlbfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r--fs/hugetlbfs/inode.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index bc56df8ce001..23a3c76711e0 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -949,6 +949,7 @@ static int can_do_hugetlb_shm(void)
949struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) 949struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
950{ 950{
951 int error = -ENOMEM; 951 int error = -ENOMEM;
952 int unlock_shm = 0;
952 struct file *file; 953 struct file *file;
953 struct inode *inode; 954 struct inode *inode;
954 struct dentry *dentry, *root; 955 struct dentry *dentry, *root;
@@ -958,8 +959,14 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
958 if (!hugetlbfs_vfsmount) 959 if (!hugetlbfs_vfsmount)
959 return ERR_PTR(-ENOENT); 960 return ERR_PTR(-ENOENT);
960 961
961 if (!can_do_hugetlb_shm()) 962 if (!can_do_hugetlb_shm()) {
962 return ERR_PTR(-EPERM); 963 if (user_shm_lock(size, user)) {
964 unlock_shm = 1;
965 WARN_ONCE(1,
966 "Using mlock ulimits for SHM_HUGETLB deprecated\n");
967 } else
968 return ERR_PTR(-EPERM);
969 }
963 970
964 root = hugetlbfs_vfsmount->mnt_root; 971 root = hugetlbfs_vfsmount->mnt_root;
965 quick_string.name = name; 972 quick_string.name = name;
@@ -999,6 +1006,8 @@ out_inode:
999out_dentry: 1006out_dentry:
1000 dput(dentry); 1007 dput(dentry);
1001out_shm_unlock: 1008out_shm_unlock:
1009 if (unlock_shm)
1010 user_shm_unlock(size, user);
1002 return ERR_PTR(error); 1011 return ERR_PTR(error);
1003} 1012}
1004 1013