unionfs(): destroy root vnode if upper registration fails

If unionfs_domount() fails, the mount path will not call VFS_UNMOUNT()
to clean up after it.  If this failure happens during upper vnode
registration, the unionfs root vnode will already be allocated.
vflush() it in order to prevent the vnode from being leaked and the
subsequent vfs_mount_destroy() call from getting stuck waiting for
the mountpoint reference count to drain.

Reviewed by:	kib, markj
Tested by:	pho
Differential Revision: https://reviews.freebsd.org/D39767
This commit is contained in:
Jason A. Harmening 2023-03-25 20:50:55 -05:00
parent 0745d837c2
commit 356e698011

View File

@ -318,6 +318,7 @@ unionfs_domount(struct mount *mp)
vfs_unregister_upper(lowermp, &ump->um_lower_link);
if (uppermp != NULL)
vfs_unregister_upper(uppermp, &ump->um_upper_link);
vflush(mp, 1, FORCECLOSE, curthread);
free(ump, M_UNIONFSMNT);
mp->mnt_data = NULL;
return (ENOENT);