From patchwork Tue May 29 20:07:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 161795 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 62E75B6FD1 for ; Wed, 30 May 2012 06:08:47 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754789Ab2E2UH7 (ORCPT ); Tue, 29 May 2012 16:07:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42498 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754403Ab2E2UH4 (ORCPT ); Tue, 29 May 2012 16:07:56 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 366FB970AD; Tue, 29 May 2012 22:07:53 +0200 (CEST) Received: by quack.suse.cz (Postfix, from userid 1000) id 1A1162061A; Tue, 29 May 2012 22:07:52 +0200 (CEST) From: Jan Kara To: Al Viro Cc: Ted Tso , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Jan Kara Subject: [PATCH 3/4] ext3: Handle error from d_splice_alias() Date: Tue, 29 May 2012 22:07:46 +0200 Message-Id: <1338322067-17566-4-git-send-email-jack@suse.cz> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1338322067-17566-1-git-send-email-jack@suse.cz> References: <1338322067-17566-1-git-send-email-jack@suse.cz> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org When directory hiearchy is corrupted and contains cycles, d_splice_alias() can fail. Handle the failure cleanly. Signed-off-by: Jan Kara --- fs/ext3/namei.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index eeb63df..faf09b7 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1016,6 +1016,7 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str struct inode * inode; struct ext3_dir_entry_2 * de; struct buffer_head * bh; + struct dentry *ret; if (dentry->d_name.len > EXT3_NAME_LEN) return ERR_PTR(-ENAMETOOLONG); @@ -1038,7 +1039,13 @@ static struct dentry *ext3_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)) { + ext3_error(dir->i_sb, __func__, "directory #%lu corrupted", + dir->i_ino); + iput(inode); + } + return ret; }