diff options
author | mjg <mjg@FreeBSD.org> | 2016-12-31 12:58:26 +0000 |
---|---|---|
committer | mjg <mjg@FreeBSD.org> | 2016-12-31 12:58:26 +0000 |
commit | 4a1aec69b8c54ceaac717e92e810f38dfbf845f2 (patch) | |
tree | 33c546427862d124cf0685fe508a1b52a87c666c /sys/kern/vfs_lookup.c | |
parent | c818a5dc7c3f9918d30ccd36f04d4c6963156902 (diff) | |
download | FreeBSD-src-4a1aec69b8c54ceaac717e92e810f38dfbf845f2.zip FreeBSD-src-4a1aec69b8c54ceaac717e92e810f38dfbf845f2.tar.gz |
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.
Diffstat (limited to 'sys/kern/vfs_lookup.c')
-rw-r--r-- | sys/kern/vfs_lookup.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index c1ad31e..0fff629 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -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); |