aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ia64/kernel/perfmon.c4
-rw-r--r--fs/anon_inodes.c8
-rw-r--r--fs/file_table.c2
-rw-r--r--fs/hugetlbfs/inode.c12
-rw-r--r--fs/pipe.c4
-rw-r--r--ipc/shm.c3
-rw-r--r--mm/shmem.c4
-rw-r--r--net/socket.c4
8 files changed, 19 insertions, 22 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index ea39eba61ef5..433f5e8a2cd1 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2221,9 +2221,9 @@ pfm_alloc_file(pfm_context_t *ctx)
2221 d_add(path.dentry, inode); 2221 d_add(path.dentry, inode);
2222 2222
2223 file = alloc_file(&path, FMODE_READ, &pfm_file_ops); 2223 file = alloc_file(&path, FMODE_READ, &pfm_file_ops);
2224 if (!file) { 2224 if (IS_ERR(file)) {
2225 path_put(&path); 2225 path_put(&path);
2226 return ERR_PTR(-ENFILE); 2226 return file;
2227 } 2227 }
2228 2228
2229 file->f_flags = O_RDONLY; 2229 file->f_flags = O_RDONLY;
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index 28d39fb84ae3..a14eb0c1cd8c 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -131,7 +131,6 @@ struct file *anon_inode_getfile(const char *name,
131 struct qstr this; 131 struct qstr this;
132 struct path path; 132 struct path path;
133 struct file *file; 133 struct file *file;
134 int error;
135 134
136 if (IS_ERR(anon_inode_inode)) 135 if (IS_ERR(anon_inode_inode))
137 return ERR_PTR(-ENODEV); 136 return ERR_PTR(-ENODEV);
@@ -143,7 +142,7 @@ struct file *anon_inode_getfile(const char *name,
143 * Link the inode to a directory entry by creating a unique name 142 * Link the inode to a directory entry by creating a unique name
144 * using the inode sequence number. 143 * using the inode sequence number.
145 */ 144 */
146 error = -ENOMEM; 145 file = ERR_PTR(-ENOMEM);
147 this.name = name; 146 this.name = name;
148 this.len = strlen(name); 147 this.len = strlen(name);
149 this.hash = 0; 148 this.hash = 0;
@@ -160,9 +159,8 @@ struct file *anon_inode_getfile(const char *name,
160 159
161 d_instantiate(path.dentry, anon_inode_inode); 160 d_instantiate(path.dentry, anon_inode_inode);
162 161
163 error = -ENFILE;
164 file = alloc_file(&path, OPEN_FMODE(flags), fops); 162 file = alloc_file(&path, OPEN_FMODE(flags), fops);
165 if (!file) 163 if (IS_ERR(file))
166 goto err_dput; 164 goto err_dput;
167 file->f_mapping = anon_inode_inode->i_mapping; 165 file->f_mapping = anon_inode_inode->i_mapping;
168 166
@@ -177,7 +175,7 @@ err_dput:
177 path_put(&path); 175 path_put(&path);
178err_module: 176err_module:
179 module_put(fops->owner); 177 module_put(fops->owner);
180 return ERR_PTR(error); 178 return file;
181} 179}
182EXPORT_SYMBOL_GPL(anon_inode_getfile); 180EXPORT_SYMBOL_GPL(anon_inode_getfile);
183 181
diff --git a/fs/file_table.c b/fs/file_table.c
index cd76d4fdf4a4..aa07d3684a2e 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -173,7 +173,7 @@ struct file *alloc_file(struct path *path, fmode_t mode,
173 173
174 file = get_empty_filp(); 174 file = get_empty_filp();
175 if (IS_ERR(file)) 175 if (IS_ERR(file))
176 return NULL; 176 return file;
177 177
178 file->f_path = *path; 178 file->f_path = *path;
179 file->f_mapping = path->dentry->d_inode->i_mapping; 179 file->f_mapping = path->dentry->d_inode->i_mapping;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index edb42ea60c76..99fe7ef2f09b 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -923,8 +923,7 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
923 struct user_struct **user, 923 struct user_struct **user,
924 int creat_flags, int page_size_log) 924 int creat_flags, int page_size_log)
925{ 925{
926 int error = -ENOMEM; 926 struct file *file = ERR_PTR(-ENOMEM);
927 struct file *file;
928 struct inode *inode; 927 struct inode *inode;
929 struct path path; 928 struct path path;
930 struct dentry *root; 929 struct dentry *root;
@@ -964,7 +963,7 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
964 goto out_shm_unlock; 963 goto out_shm_unlock;
965 964
966 path.mnt = mntget(hugetlbfs_vfsmount[hstate_idx]); 965 path.mnt = mntget(hugetlbfs_vfsmount[hstate_idx]);
967 error = -ENOSPC; 966 file = ERR_PTR(-ENOSPC);
968 inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0); 967 inode = hugetlbfs_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0);
969 if (!inode) 968 if (!inode)
970 goto out_dentry; 969 goto out_dentry;
@@ -973,7 +972,7 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
973 size += addr & ~huge_page_mask(hstate); 972 size += addr & ~huge_page_mask(hstate);
974 num_pages = ALIGN(size, huge_page_size(hstate)) >> 973 num_pages = ALIGN(size, huge_page_size(hstate)) >>
975 huge_page_shift(hstate); 974 huge_page_shift(hstate);
976 error = -ENOMEM; 975 file = ERR_PTR(-ENOMEM);
977 if (hugetlb_reserve_pages(inode, 0, num_pages, NULL, acctflag)) 976 if (hugetlb_reserve_pages(inode, 0, num_pages, NULL, acctflag))
978 goto out_inode; 977 goto out_inode;
979 978
@@ -981,10 +980,9 @@ struct file *hugetlb_file_setup(const char *name, unsigned long addr,
981 inode->i_size = size; 980 inode->i_size = size;
982 clear_nlink(inode); 981 clear_nlink(inode);
983 982
984 error = -ENFILE;
985 file = alloc_file(&path, FMODE_WRITE | FMODE_READ, 983 file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
986 &hugetlbfs_file_operations); 984 &hugetlbfs_file_operations);
987 if (!file) 985 if (IS_ERR(file))
988 goto out_dentry; /* inode is already attached */ 986 goto out_dentry; /* inode is already attached */
989 987
990 return file; 988 return file;
@@ -998,7 +996,7 @@ out_shm_unlock:
998 user_shm_unlock(size, *user); 996 user_shm_unlock(size, *user);
999 *user = NULL; 997 *user = NULL;
1000 } 998 }
1001 return ERR_PTR(error); 999 return file;
1002} 1000}
1003 1001
1004static int __init init_hugetlbfs_fs(void) 1002static int __init init_hugetlbfs_fs(void)
diff --git a/fs/pipe.c b/fs/pipe.c
index 39baf6c3ebb0..64a494cef0a0 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -1037,13 +1037,13 @@ int create_pipe_files(struct file **res, int flags)
1037 1037
1038 err = -ENFILE; 1038 err = -ENFILE;
1039 f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); 1039 f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops);
1040 if (!f) 1040 if (IS_ERR(f))
1041 goto err_dentry; 1041 goto err_dentry;
1042 1042
1043 f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)); 1043 f->f_flags = O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT));
1044 1044
1045 res[0] = alloc_file(&path, FMODE_READ, &read_pipefifo_fops); 1045 res[0] = alloc_file(&path, FMODE_READ, &read_pipefifo_fops);
1046 if (!res[0]) 1046 if (IS_ERR(res[0]))
1047 goto err_file; 1047 goto err_file;
1048 1048
1049 path_get(&path); 1049 path_get(&path);
diff --git a/ipc/shm.c b/ipc/shm.c
index 8c9402d298a0..de389e639e7e 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1042,7 +1042,8 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
1042 is_file_hugepages(shp->shm_file) ? 1042 is_file_hugepages(shp->shm_file) ?
1043 &shm_file_operations_huge : 1043 &shm_file_operations_huge :
1044 &shm_file_operations); 1044 &shm_file_operations);
1045 if (!file) 1045 err = PTR_ERR(file);
1046 if (IS_ERR(file))
1046 goto out_free; 1047 goto out_free;
1047 1048
1048 file->private_data = sfd; 1049 file->private_data = sfd;
diff --git a/mm/shmem.c b/mm/shmem.c
index 814d5546cb35..abf07f754277 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2913,10 +2913,10 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
2913 goto put_dentry; 2913 goto put_dentry;
2914#endif 2914#endif
2915 2915
2916 error = -ENFILE;
2917 file = alloc_file(&path, FMODE_WRITE | FMODE_READ, 2916 file = alloc_file(&path, FMODE_WRITE | FMODE_READ,
2918 &shmem_file_operations); 2917 &shmem_file_operations);
2919 if (!file) 2918 error = PTR_ERR(file);
2919 if (IS_ERR(file))
2920 goto put_dentry; 2920 goto put_dentry;
2921 2921
2922 return file; 2922 return file;
diff --git a/net/socket.c b/net/socket.c
index 2ca51c719ef9..f4a8c5a0b8d7 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -370,11 +370,11 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname)
370 370
371 file = alloc_file(&path, FMODE_READ | FMODE_WRITE, 371 file = alloc_file(&path, FMODE_READ | FMODE_WRITE,
372 &socket_file_ops); 372 &socket_file_ops);
373 if (unlikely(!file)) { 373 if (unlikely(IS_ERR(file))) {
374 /* drop dentry, keep inode */ 374 /* drop dentry, keep inode */
375 ihold(path.dentry->d_inode); 375 ihold(path.dentry->d_inode);
376 path_put(&path); 376 path_put(&path);
377 return ERR_PTR(-ENFILE); 377 return file;
378 } 378 }
379 379
380 sock->file = file; 380 sock->file = file;