Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

configfs: sanitize configfs_create()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 16d13b59 b7c177fc

+27 -28
+27 -28
fs/configfs/inode.c
··· 187 187 int configfs_create(struct dentry * dentry, umode_t mode, int (*init)(struct inode *)) 188 188 { 189 189 int error = 0; 190 - struct inode * inode = NULL; 191 - if (dentry) { 192 - if (!dentry->d_inode) { 193 - struct configfs_dirent *sd = dentry->d_fsdata; 194 - if ((inode = configfs_new_inode(mode, sd, dentry->d_sb))) { 195 - if (dentry->d_parent && dentry->d_parent->d_inode) { 196 - struct inode *p_inode = dentry->d_parent->d_inode; 197 - p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; 198 - } 199 - configfs_set_inode_lock_class(sd, inode); 200 - goto Proceed; 201 - } 202 - else 203 - error = -ENOMEM; 204 - } else 205 - error = -EEXIST; 206 - } else 207 - error = -ENOENT; 208 - goto Done; 190 + struct inode *inode = NULL; 191 + struct configfs_dirent *sd; 192 + struct inode *p_inode; 209 193 210 - Proceed: 211 - if (init) 194 + if (!dentry) 195 + return -ENOENT; 196 + 197 + if (dentry->d_inode) 198 + return -EEXIST; 199 + 200 + sd = dentry->d_fsdata; 201 + inode = configfs_new_inode(mode, sd, dentry->d_sb); 202 + if (!inode) 203 + return -ENOMEM; 204 + 205 + p_inode = dentry->d_parent->d_inode; 206 + p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; 207 + configfs_set_inode_lock_class(sd, inode); 208 + 209 + if (init) { 212 210 error = init(inode); 213 - if (!error) { 214 - d_instantiate(dentry, inode); 215 - if (S_ISDIR(mode) || S_ISLNK(mode)) 216 - dget(dentry); /* pin link and directory dentries in core */ 217 - } else 218 - iput(inode); 219 - Done: 211 + if (error) { 212 + iput(inode); 213 + return error; 214 + } 215 + } 216 + d_instantiate(dentry, inode); 217 + if (S_ISDIR(mode) || S_ISLNK(mode)) 218 + dget(dentry); /* pin link and directory dentries in core */ 220 219 return error; 221 220 } 222 221