Date: Sun, 10 Oct 2021 18:24:38 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 93e0523499fe - main - vfs: add predicts to getvnode and getvnode_path Message-ID: <202110101824.19AIOc18024487@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=93e0523499fecb2ce1ca434c8ab96b58559771f3 commit 93e0523499fecb2ce1ca434c8ab96b58559771f3 Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-10-10 18:17:50 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-10-10 18:24:29 +0000 vfs: add predicts to getvnode and getvnode_path --- sys/kern/vfs_syscalls.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 1b355eea7d6a..82a8125ece95 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -4316,7 +4316,7 @@ getvnode_path(struct thread *td, int fd, cap_rights_t *rightsp, * other thread to dereference it. Guard against the race by * checking f_ops. */ - if (fp->f_vnode == NULL || fp->f_ops == &badfileops) { + if (__predict_false(fp->f_vnode == NULL || fp->f_ops == &badfileops)) { fdrop(fp, td); return (EINVAL); } @@ -4336,12 +4336,14 @@ getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp) int error; error = getvnode_path(td, fd, rightsp, fpp); + if (__predict_false(error != 0)) + return (error); /* * Filter out O_PATH file descriptors, most getvnode() callers * do not call fo_ methods. */ - if (error == 0 && (*fpp)->f_ops == &path_fileops) { + if (__predict_false((*fpp)->f_ops == &path_fileops)) { fdrop(*fpp, td); error = EBADF; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110101824.19AIOc18024487>