From owner-svn-src-stable-11@freebsd.org Sat Dec 31 12:58:28 2016 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4CF39C98BB6; Sat, 31 Dec 2016 12:58:28 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E936C13CE; Sat, 31 Dec 2016 12:58:27 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBVCwR7Z088595; Sat, 31 Dec 2016 12:58:27 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBVCwRbs088594; Sat, 31 Dec 2016 12:58:27 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201612311258.uBVCwRbs088594@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 31 Dec 2016 12:58:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r310968 - stable/11/sys/kern X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Dec 2016 12:58:28 -0000 Author: mjg Date: Sat Dec 31 12:58:26 2016 New Revision: 310968 URL: https://svnweb.freebsd.org/changeset/base/310968 Log: MFC r304927: vfs: provide a common exit point in namei for error cases This shortens the function, adds the SDT_PROBE use for error cases and consistenly unrefs rootdir last. Modified: stable/11/sys/kern/vfs_lookup.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_lookup.c ============================================================================== --- stable/11/sys/kern/vfs_lookup.c Sat Dec 31 12:52:58 2016 (r310967) +++ stable/11/sys/kern/vfs_lookup.c Sat Dec 31 12:58:26 2016 (r310968) @@ -380,9 +380,7 @@ namei(struct nameidata *ndp) if (error != 0) { if (dp != NULL) vrele(dp); - vrele(ndp->ni_rootdir); - namei_cleanup_cnp(cnp); - return (error); + goto out; } if ((ndp->ni_lcf & NI_LCF_STRICTRELATIVE) != 0 && lookup_cap_dotdot != 0) @@ -392,12 +390,8 @@ namei(struct nameidata *ndp) for (;;) { ndp->ni_startdir = dp; error = lookup(ndp); - if (error != 0) { - vrele(ndp->ni_rootdir); - namei_cleanup_cnp(cnp); - SDT_PROBE2(vfs, namei, lookup, return, error, NULL); - return (error); - } + if (error != 0) + goto out; /* * If not a symbolic link, we're done. */ @@ -471,18 +465,16 @@ namei(struct nameidata *ndp) if (*(cnp->cn_nameptr) == '/') { vrele(dp); error = namei_handle_root(ndp, &dp); - if (error != 0) { - vrele(ndp->ni_rootdir); - namei_cleanup_cnp(cnp); - return (error); - } + if (error != 0) + goto out; } } - vrele(ndp->ni_rootdir); - namei_cleanup_cnp(cnp); vput(ndp->ni_vp); ndp->ni_vp = NULL; vrele(ndp->ni_dvp); +out: + vrele(ndp->ni_rootdir); + namei_cleanup_cnp(cnp); nameicap_cleanup(ndp); SDT_PROBE2(vfs, namei, lookup, return, error, NULL); return (error);