Thread (11 messages) 11 messages, 4 authors, 2012-06-12
STALE5136d

[PATCH 2/4] ext2: Handle error from d_splice_alias()

From: Jan Kara <jack@suse.cz>
Date: 2012-05-29 20:07:56
Also in: linux-fsdevel
Subsystem: ext2 file system, filesystems (vfs and infrastructure), the rest · Maintainers: Jan Kara, Alexander Viro, Christian Brauner, Linus Torvalds

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/ext2/namei.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index f663a67..d5f8aab 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -59,6 +59,7 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
 {
 	struct inode * inode;
 	ino_t ino;
+	struct dentry *ret;
 	
 	if (dentry->d_name.len > EXT2_NAME_LEN)
 		return ERR_PTR(-ENAMETOOLONG);
@@ -74,7 +75,13 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, str
 			return ERR_PTR(-EIO);
 		}
 	}
-	return d_splice_alias(inode, dentry);
+	ret = d_splice_alias(inode, dentry);
+	if (IS_ERR(ret)) {
+		ext2_error(dir->i_sb, __func__, "directory #%lu corrupted",
+			   dir->i_ino);
+		iput(inode);
+	}
+	return ret;
 }
 
 struct dentry *ext2_get_parent(struct dentry *child)
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help