aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hugetlbfs/inode.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-08-08 16:52:35 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:42 -0500
commit2c48b9c45579a9b5e3e74694eebf3d2451f3dbd3 (patch)
treececbf786ae0650368a8136bdd90910e05d9b95c3 /fs/hugetlbfs/inode.c
parenta95161aaa801c18c52b2e7cf3d6b4b141c00a20a (diff)
switch alloc_file() to passing struct path
... and have the caller grab both mnt and dentry; kill leak in infiniband, while we are at it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/hugetlbfs/inode.c')
-rw-r--r--fs/hugetlbfs/inode.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 87a1258953b8..6bd41525cd71 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -922,7 +922,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
922 int error = -ENOMEM; 922 int error = -ENOMEM;
923 struct file *file; 923 struct file *file;
924 struct inode *inode; 924 struct inode *inode;
925 struct dentry *dentry, *root; 925 struct path path;
926 struct dentry *root;
926 struct qstr quick_string; 927 struct qstr quick_string;
927 928
928 *user = NULL; 929 *user = NULL;
@@ -944,10 +945,11 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
944 quick_string.name = name; 945 quick_string.name = name;
945 quick_string.len = strlen(quick_string.name); 946 quick_string.len = strlen(quick_string.name);
946 quick_string.hash = 0; 947 quick_string.hash = 0;
947 dentry = d_alloc(root, &quick_string); 948 path.dentry = d_alloc(root, &quick_string);
948 if (!dentry) 949 if (!path.dentry)
949 goto out_shm_unlock; 950 goto out_shm_unlock;
950 951
952 path.mnt = mntget(hugetlbfs_vfsmount);
951 error = -ENOSPC; 953 error = -ENOSPC;
952 inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), 954 inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(),
953 current_fsgid(), S_IFREG | S_IRWXUGO, 0); 955 current_fsgid(), S_IFREG | S_IRWXUGO, 0);
@@ -960,13 +962,12 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
960 acctflag)) 962 acctflag))
961 goto out_inode; 963 goto out_inode;
962 964
963 d_instantiate(dentry, inode); 965 d_instantiate(path.dentry, inode);
964 inode->i_size = size; 966 inode->i_size = size;
965 inode->i_nlink = 0; 967 inode->i_nlink = 0;
966 968
967 error = -ENFILE; 969 error = -ENFILE;
968 file = alloc_file(hugetlbfs_vfsmount, dentry, 970 file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
969 FMODE_WRITE | FMODE_READ,
970 &hugetlbfs_file_operations); 971 &hugetlbfs_file_operations);
971 if (!file) 972 if (!file)
972 goto out_dentry; /* inode is already attached */ 973 goto out_dentry; /* inode is already attached */
@@ -977,7 +978,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
977out_inode: 978out_inode:
978 iput(inode); 979 iput(inode);
979out_dentry: 980out_dentry:
980 dput(dentry); 981 path_put(&path);
981out_shm_unlock: 982out_shm_unlock:
982 if (*user) { 983 if (*user) {
983 user_shm_unlock(size, *user); 984 user_shm_unlock(size, *user);