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

ubifs_lookup: use d_splice_alias()

code is simpler that way

Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 191ac107 5bf35449

+15 -28
+15 -28
fs/ubifs/dir.c
··· 214 214 int err; 215 215 union ubifs_key key; 216 216 struct inode *inode = NULL; 217 - struct ubifs_dent_node *dent; 217 + struct ubifs_dent_node *dent = NULL; 218 218 struct ubifs_info *c = dir->i_sb->s_fs_info; 219 219 struct fscrypt_name nm; 220 220 ··· 229 229 return ERR_PTR(err); 230 230 231 231 if (fname_len(&nm) > UBIFS_MAX_NLEN) { 232 - err = -ENAMETOOLONG; 233 - goto out_fname; 232 + inode = ERR_PTR(-ENAMETOOLONG); 233 + goto done; 234 234 } 235 235 236 236 dent = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS); 237 237 if (!dent) { 238 - err = -ENOMEM; 239 - goto out_fname; 238 + inode = ERR_PTR(-ENOMEM); 239 + goto done; 240 240 } 241 241 242 242 if (nm.hash) { ··· 250 250 } 251 251 252 252 if (err) { 253 - if (err == -ENOENT) { 253 + if (err == -ENOENT) 254 254 dbg_gen("not found"); 255 - goto done; 256 - } 257 - goto out_dent; 255 + else 256 + inode = ERR_PTR(err); 257 + goto done; 258 258 } 259 259 260 260 if (dbg_check_name(c, dent, &nm)) { 261 - err = -EINVAL; 262 - goto out_dent; 261 + inode = ERR_PTR(-EINVAL); 262 + goto done; 263 263 } 264 264 265 265 inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum)); ··· 272 272 ubifs_err(c, "dead directory entry '%pd', error %d", 273 273 dentry, err); 274 274 ubifs_ro_mode(c, err); 275 - goto out_dent; 275 + goto done; 276 276 } 277 277 278 278 if (ubifs_crypt_is_encrypted(dir) && ··· 280 280 !fscrypt_has_permitted_context(dir, inode)) { 281 281 ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu", 282 282 dir->i_ino, inode->i_ino); 283 - err = -EPERM; 284 - goto out_inode; 283 + iput(inode); 284 + inode = ERR_PTR(-EPERM); 285 285 } 286 286 287 287 done: 288 288 kfree(dent); 289 289 fscrypt_free_filename(&nm); 290 - /* 291 - * Note, d_splice_alias() would be required instead if we supported 292 - * NFS. 293 - */ 294 - d_add(dentry, inode); 295 - return NULL; 296 - 297 - out_inode: 298 - iput(inode); 299 - out_dent: 300 - kfree(dent); 301 - out_fname: 302 - fscrypt_free_filename(&nm); 303 - return ERR_PTR(err); 290 + return d_splice_alias(inode, dentry); 304 291 } 305 292 306 293 static int ubifs_create(struct inode *dir, struct dentry *dentry, umode_t mode,