Skip to content

Commit e876c44

Browse files
author
Al Viro
committed
hpfs: fix an inode leak in lookup, switch to d_splice_alias()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent ce397d2 commit e876c44

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

‎fs/hpfs/dir.c‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
244244
result = iget_locked(dir->i_sb, ino);
245245
if (!result) {
246246
hpfs_error(dir->i_sb, "hpfs_lookup: can't get inode");
247+
result = ERR_PTR(-ENOMEM);
247248
goto bail1;
248249
}
249250
if (result->i_state & I_NEW) {
@@ -266,6 +267,8 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
266267

267268
if (de->has_acl || de->has_xtd_perm) if (!sb_rdonly(dir->i_sb)) {
268269
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");
270+
iput(result);
271+
result = ERR_PTR(-EINVAL);
269272
goto bail1;
270273
}
271274

@@ -301,29 +304,17 @@ struct dentry *hpfs_lookup(struct inode *dir, struct dentry *dentry, unsigned in
301304
}
302305
}
303306

307+
bail1:
304308
hpfs_brelse4(&qbh);
305309

306310
/*
307311
* Made it.
308312
*/
309313

310-
end:
311-
end_add:
314+
end:
315+
end_add:
312316
hpfs_unlock(dir->i_sb);
313-
d_add(dentry, result);
314-
return NULL;
315-
316-
/*
317-
* Didn't.
318-
*/
319-
bail1:
320-
321-
hpfs_brelse4(&qbh);
322-
323-
/*bail:*/
324-
325-
hpfs_unlock(dir->i_sb);
326-
return ERR_PTR(-ENOENT);
317+
return d_splice_alias(result, dentry);
327318
}
328319

329320
const struct file_operations hpfs_dir_ops =

0 commit comments

Comments
 (0)