From 99c66d3acf539e25ce9978c16e4dda3940c041fb Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Thu, 26 Nov 2020 18:13:33 +0000 Subject: [PATCH] vn_read_from_obj(): fix handling of doomed vnodes. There is no reason why vp->v_object cannot be NULL. If it is, it's fine, handle it by delegating to VOP_READ(). Tested by: pho Reviewed by: markj, mjg Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27327 --- sys/kern/vfs_vnops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index f65d44122af..832ff9ac34a 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -870,10 +870,10 @@ vn_read_from_obj(struct vnode *vp, struct uio *uio) ssize_t resid; int error, i, j; - obj = vp->v_object; MPASS(uio->uio_resid <= ptoa(io_hold_cnt + 2)); - MPASS(obj != NULL); - MPASS(obj->type == OBJT_VNODE); + obj = atomic_load_ptr(&vp->v_object); + if (obj == NULL) + return (EJUSTRETURN); /* * Depends on type stability of vm_objects.