git: fc595a6b7664 - main - Fix "vrefact: wrong use count 0" with DRM

From: Edward Tomasz Napierala <trasz_at_FreeBSD.org>
Date: Wed, 13 Nov 2024 10:29:02 UTC
The branch main has been updated by trasz:

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

commit fc595a6b76642dfdfdb8e6f9b9bbc734e95fb59c
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2024-11-13 10:00:38 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2024-11-13 10:25:57 +0000

    Fix "vrefact: wrong use count 0" with DRM
    
    Bump the vnode use count, not its hold count. This fixes a panic triggered
    by fstatat(..., AT_EMPTY_PATH) on DRM device nodes, which happens to be
    what glxinfo(1) from Ubuntu Jammy is doing.
    
    PR:             kern/274538
    Reviewed By:    kib (earlier version), olce
    Differential Revision:  https://reviews.freebsd.org/D47391
---
 sys/compat/linuxkpi/common/src/linux_compat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 81d24603d1dd..8f705cd3b2ce 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -772,7 +772,7 @@ linux_dev_fdopen(struct cdev *dev, int fflags, struct thread *td,
 	}
 
 	/* hold on to the vnode - used for fstat() */
-	vhold(filp->f_vnode);
+	vref(filp->f_vnode);
 
 	/* release the file from devfs */
 	finit(file, filp->f_mode, DTYPE_DEV, filp, &linuxfileops);
@@ -1504,7 +1504,7 @@ linux_file_close(struct file *file, struct thread *td)
 		error = -OPW(file, td, release(filp->f_vnode, filp));
 	funsetown(&filp->f_sigio);
 	if (filp->f_vnode != NULL)
-		vdrop(filp->f_vnode);
+		vrele(filp->f_vnode);
 	linux_drop_fop(ldev);
 	ldev = filp->f_cdev;
 	if (ldev != NULL)