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

hpfs: fix an inode leak in lookup, switch to d_splice_alias()

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

Al Viro e876c445 ce397d21

+7 -16
+7 -16
fs/hpfs/dir.c
··· 244 244 result = iget_locked(dir->i_sb, ino); 245 245 if (!result) { 246 246 hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode"); 247 + result = ERR_PTR(-ENOMEM); 247 248 goto bail1; 248 249 } 249 250 if (result->i_state & I_NEW) { ··· 267 266 268 267 if (de->has_acl || de->has_xtd_perm) if (!sb_rdonly(dir->i_sb)) { 269 268 hpfs_error(result->i_sb, "ACLs or XPERM found. This is probably HPFS386. This driver doesn't support it now. Send me some info on these structures"); 269 + iput(result); 270 + result = ERR_PTR(-EINVAL); 270 271 goto bail1; 271 272 } 272 273 ··· 304 301 } 305 302 } 306 303 304 + bail1: 307 305 hpfs_brelse4(&qbh); 308 306 309 307 /* 310 308 * Made it. 311 309 */ 312 310 313 - end: 314 - end_add: 311 + end: 312 + end_add: 315 313 hpfs_unlock(dir->i_sb); 316 - d_add(dentry, result); 317 - return NULL; 318 - 319 - /* 320 - * Didn't. 321 - */ 322 - bail1: 323 - 324 - hpfs_brelse4(&qbh); 325 - 326 - /*bail:*/ 327 - 328 - hpfs_unlock(dir->i_sb); 329 - return ERR_PTR(-ENOENT); 314 + return d_splice_alias(result, dentry); 330 315 } 331 316 332 317 const struct file_operations hpfs_dir_ops =