From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Kent Subject: [PATCH 2/3] vfs - fix dentry ref count in do_lookup() Date: Tue, 18 Jan 2011 12:06:10 +0800 Message-ID: <20110118040610.23109.32868.stgit@localhost6.localdomain6> References: <20110118040449.23109.33071.stgit@localhost6.localdomain6> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: Al Viro , Kernel Mailing List , linux-fsdevel , Linus Torvalds , Andrew Morton To: Nick Piggin , David Howells Return-path: Received: from outbound.icp-qv1-irony-out6.iinet.net.au ([203.59.1.109]:4817 "EHLO outbound.icp-qv1-irony-out6.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753539Ab1AREPW (ORCPT ); Mon, 17 Jan 2011 23:15:22 -0500 In-Reply-To: <20110118040449.23109.33071.stgit@localhost6.localdomain6> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: There is a ref count problem in fs/namei.c:do_lookup(). When walking in ref-walk mode, if follow_managed() returns a fail the reference held by path.dentry isn't dropped. --- fs/namei.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index b753192..dbc36ff 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1272,8 +1272,11 @@ done: path->mnt = mnt; path->dentry = dentry; err = follow_managed(path, nd->flags); - if (unlikely(err < 0)) + if (unlikely(err < 0)) { + if (!(nd->flags & LOOKUP_RCU)) + dput(dentry); return err; + } *inode = path->dentry->d_inode; return 0;