From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: [PATCH 2/5] ext2: Handle error from d_splice_alias() Date: Wed, 20 Jun 2012 22:58:37 +0200 Message-ID: <1340225920-29379-2-git-send-email-jack@suse.cz> References: <1340225920-29379-1-git-send-email-jack@suse.cz> Cc: linux-fsdevel@vger.kernel.org, Jan Kara To: Al Viro Return-path: Received: from cantor2.suse.de ([195.135.220.15]:43463 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753967Ab2FTU6n (ORCPT ); Wed, 20 Jun 2012 16:58:43 -0400 In-Reply-To: <1340225920-29379-1-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: When directory hiearchy is corrupted and contains cycles, d_splice_alias() can fail. Warn user and mark filesystem as with errors when that happens. Signed-off-by: Jan Kara --- fs/ext2/namei.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index f663a67..b3f074b 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,12 @@ 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); + } + return ret; } struct dentry *ext2_get_parent(struct dentry *child) -- 1.7.1