From patchwork Wed May 13 22:26:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 6400921 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6BC49F1C2 for ; Wed, 13 May 2015 22:30:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18EBE20320 for ; Wed, 13 May 2015 22:30:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BD6420304 for ; Wed, 13 May 2015 22:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965805AbbEMW3i (ORCPT ); Wed, 13 May 2015 18:29:38 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:44936 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965489AbbEMW0U (ORCPT ); Wed, 13 May 2015 18:26:20 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1Ysf6W-0006mr-SI; Wed, 13 May 2015 22:26:16 +0000 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 15/21] namei: fold path_cleanup() into terminate_walk() Date: Wed, 13 May 2015 23:26:09 +0100 Message-Id: <1431555975-25997-15-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150513222533.GA24192@ZenIV.linux.org.uk> References: <20150513222533.GA24192@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Al Viro they are always called next to each other; moreover, terminate_walk() is more symmetrical that way. Signed-off-by: Al Viro --- fs/namei.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index bd45300..59a4662 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -584,6 +584,10 @@ static void terminate_walk(struct nameidata *nd) path_put(&nd->path); for (i = 0; i < nd->depth; i++) path_put(&nd->stack[i].link); + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { + path_put(&nd->root); + nd->root.mnt = NULL; + } } else { nd->flags &= ~LOOKUP_RCU; if (!(nd->flags & LOOKUP_ROOT)) @@ -2049,14 +2053,6 @@ static const char *path_init(int dfd, const struct filename *name, return ERR_PTR(-ECHILD); } -static void path_cleanup(struct nameidata *nd) -{ - if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT)) { - path_put(&nd->root); - nd->root.mnt = NULL; - } -} - static const char *trailing_symlink(struct nameidata *nd) { const char *s; @@ -2112,7 +2108,6 @@ static int path_lookupat(int dfd, const struct filename *name, unsigned flags, nd->path.dentry = NULL; } terminate_walk(nd); - path_cleanup(nd); return err; } @@ -2160,7 +2155,6 @@ static int path_parentat(int dfd, const struct filename *name, nd->path.dentry = NULL; } terminate_walk(nd); - path_cleanup(nd); return err; } @@ -2444,7 +2438,6 @@ path_mountpoint(int dfd, const struct filename *name, struct path *path, } } terminate_walk(nd); - path_cleanup(nd); return err; } @@ -3316,7 +3309,6 @@ static struct file *path_openat(int dfd, struct filename *pathname, } } terminate_walk(nd); - path_cleanup(nd); out2: if (!(opened & FILE_OPENED)) { BUG_ON(!error);