From patchwork Tue Jun 28 05:53:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsutomu Itoh X-Patchwork-Id: 923152 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5S5u5Ik026256 for ; Tue, 28 Jun 2011 05:56:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756618Ab1F1Fz0 (ORCPT ); Tue, 28 Jun 2011 01:55:26 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:36270 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756260Ab1F1Fy5 (ORCPT ); Tue, 28 Jun 2011 01:54:57 -0400 Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 82BB03EE0B5 for ; Tue, 28 Jun 2011 14:54:55 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 69B0E45DE57 for ; Tue, 28 Jun 2011 14:54:55 +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 525F745DE91 for ; Tue, 28 Jun 2011 14:54:55 +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 4280B1DB8037 for ; Tue, 28 Jun 2011 14:54:55 +0900 (JST) Received: from m107.s.css.fujitsu.com (m107.s.css.fujitsu.com [10.240.81.147]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 05D161DB802F for ; Tue, 28 Jun 2011 14:54:55 +0900 (JST) Received: from m107.css.fujitsu.com (m107 [127.0.0.1]) by m107.s.css.fujitsu.com (Postfix) with ESMTP id C202D67001C; Tue, 28 Jun 2011 14:54:54 +0900 (JST) Received: from T-ITOH1.jp.fujitsu.com (unknown [10.124.101.84]) by m107.s.css.fujitsu.com (Postfix) with SMTP id 6433A670015; Tue, 28 Jun 2011 14:54:54 +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 14:54:11 +0900 (JST) Message-Id: <201106280553.AA00028@T-ITOH1.jp.fujitsu.com> From: Tsutomu Itoh Date: Tue, 28 Jun 2011 14:53:55 +0900 To: linux-btrfs@vger.kernel.org Cc: chris.mason@oracle.com Subject: [PATCH v2] 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 (demeter2.kernel.org [140.211.167.43]); Tue, 28 Jun 2011 05:56:07 +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 --- V1 -> V2: unnecessary BUG_ON was deleted fs/btrfs/ioctl.c | 10 +++++++++- 1 files changed, 9 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/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) {