Comments
Patch
@@ -1024,6 +1024,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
struct inode *inode;
struct ext4_dir_entry_2 *de;
struct buffer_head *bh;
+ struct dentry *ret;
if (dentry->d_name.len > EXT4_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
@@ -1045,7 +1046,12 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
return ERR_PTR(-EIO);
}
}
- return d_splice_alias(inode, dentry);
+ ret = d_splice_alias(inode, dentry);
+ if (IS_ERR(ret)) {
+ EXT4_ERROR_INODE(dir, "directory corrupted");
+ iput(inode);
+ }
+ return ret;
}
When directory hiearchy is corrupted and contains cycles, d_splice_alias() can fail. Handle the failure cleanly. Signed-off-by: Jan Kara <jack@suse.cz> --- fs/ext4/namei.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)