The branch main has been updated by mjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=93e0523499fecb2ce1ca434c8ab96b58559771f3

commit 93e0523499fecb2ce1ca434c8ab96b58559771f3
Author:     Mateusz Guzik <m...@freebsd.org>
AuthorDate: 2021-10-10 18:17:50 +0000
Commit:     Mateusz Guzik <m...@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;
        }

Reply via email to