From patchwork Tue Jun 28 03:34:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 923082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5S3c7WC030785 for ; Tue, 28 Jun 2011 03:38:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756177Ab1F1Dgx (ORCPT ); Mon, 27 Jun 2011 23:36:53 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:35077 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756352Ab1F1DgT (ORCPT ); Mon, 27 Jun 2011 23:36:19 -0400 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 2BDD23EE0B6 for ; Tue, 28 Jun 2011 12:36:16 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 1412145DE91 for ; Tue, 28 Jun 2011 12:36:16 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id F2F1E45DE5B for ; Tue, 28 Jun 2011 12:36:15 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id E6C721DB8037 for ; Tue, 28 Jun 2011 12:36:15 +0900 (JST) Received: from m105.s.css.fujitsu.com (m105.s.css.fujitsu.com [10.240.81.145]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id B58FF1DB802F for ; Tue, 28 Jun 2011 12:36:15 +0900 (JST) Received: from m105.css.fujitsu.com (m105 [127.0.0.1]) by m105.s.css.fujitsu.com (Postfix) with ESMTP id 39DFC9C8007; Tue, 28 Jun 2011 12:36:15 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.84]) by m105.s.css.fujitsu.com (Postfix) with SMTP id DAD809C8006; Tue, 28 Jun 2011 12:36:13 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.4.0 Received: from T-ITOH1[10.124.101.84] by T-ITOH1 (FujitsuOutboundMailChecker v1.4.0/9992[10.124.101.84]); Tue, 28 Jun 2011 12:35:29 +0900 (JST) Message-Id: <201106280334.AA00027@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Tue, 28 Jun 2011 12:34:49 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH] Btrfs: fix error check of btrfs_lookup_dentry() MIME-Version: 1.0 X-Mailer: AL-Mail32 Version 1.13 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 28 Jun 2011 03:38:08 +0000 (UTC) The return value of btrfs_lookup_dentry is checked so that the panic such as illegal address reference should not occur. Signed-off-by: Tsutomu Itoh --- fs/btrfs/inode.c | 1 + fs/btrfs/ioctl.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 447612d..1364ae8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4082,6 +4082,7 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, inode = btrfs_lookup_dentry(dir, dentry); if (IS_ERR(inode)) return ERR_CAST(inode); + BUG_ON(!inode); return d_splice_alias(inode, dentry); } diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a3c4751..39c62d3 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -325,6 +325,7 @@ static noinline int create_subvol(struct btrfs_root *root, struct btrfs_root *new_root; struct dentry *parent = dget_parent(dentry); struct inode *dir; + struct inode *inode; int ret; int err; u64 objectid; @@ -437,7 +438,14 @@ static noinline int create_subvol(struct btrfs_root *root, BUG_ON(ret); - d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); + inode = btrfs_lookup_dentry(dir, dentry); + if (IS_ERR(inode)) { + ret = PTR_ERR(inode); + goto fail; + } + BUG_ON(!inode); + + d_instantiate(dentry, inode); fail: dput(parent); if (async_transid) {