From patchwork Tue May 5 05:22:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 6335111 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 F33759F32E for ; Tue, 5 May 2015 05:40:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3144E201F4 for ; Tue, 5 May 2015 05:40:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D989202BE for ; Tue, 5 May 2015 05:40:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965578AbbEEFet (ORCPT ); Tue, 5 May 2015 01:34:49 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:40015 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755623AbbEEFXH (ORCPT ); Tue, 5 May 2015 01:23:07 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.76 #1 (Red Hat Linux)) id 1YpVJw-0001OB-Lj; Tue, 05 May 2015 05:23:04 +0000 From: Al Viro To: Linus Torvalds Cc: Neil Brown , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 68/79] namei: have terminate_walk() do put_link() on everything left Date: Tue, 5 May 2015 06:22:42 +0100 Message-Id: <1430803373-4948-68-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <20150505052205.GS889@ZenIV.linux.org.uk> References: <20150505052205.GS889@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 All callers of terminate_walk() are followed by more or less open-coded eqiuvalent of "do put_link() on everything left in nd->stack". Better done in terminate_walk() itself, and when we go for RCU symlink traversal we'll have to do it there anyway. Signed-off-by: Al Viro --- fs/namei.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 0fbc9b7..3faf3e2 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1554,6 +1554,8 @@ static void terminate_walk(struct nameidata *nd) nd->root.mnt = NULL; rcu_read_unlock(); } + while (unlikely(nd->depth)) + put_link(nd); } /* @@ -1848,8 +1850,6 @@ Walked: } } terminate_walk(nd); - while (unlikely(nd->depth)) - put_link(nd); return err; OK: if (!nd->depth) /* called from path_init(), done */ @@ -2366,8 +2366,6 @@ done: error = 0; out: terminate_walk(nd); - if (nd->depth) - put_link(nd); return error; } @@ -2970,8 +2968,6 @@ static int do_last(struct nameidata *nd, error = handle_dots(nd, nd->last_type); if (unlikely(error)) { terminate_walk(nd); - if (nd->depth) - put_link(nd); return error; } goto finish_open; @@ -3170,8 +3166,6 @@ out: mnt_drop_write(nd->path.mnt); path_put(&save_parent); terminate_walk(nd); - if (nd->depth) - put_link(nd); return error; exit_dput: