svn commit: r367357 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Thu Nov 5 02:12:09 UTC 2020


Author: mjg
Date: Thu Nov  5 02:12:08 2020
New Revision: 367357
URL: https://svnweb.freebsd.org/changeset/base/367357

Log:
  fd: hide _fdrop 0 count check behind INVARIANTS
  
  While here use refcount_load and make sure to report the tested value.

Modified:
  head/sys/kern/kern_descrip.c

Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c	Thu Nov  5 00:52:52 2020	(r367356)
+++ head/sys/kern/kern_descrip.c	Thu Nov  5 02:12:08 2020	(r367357)
@@ -3219,9 +3219,13 @@ int __noinline
 _fdrop(struct file *fp, struct thread *td)
 {
 	int error;
+#ifdef INVARIANTS
+	int count;
 
-	if (fp->f_count != 0)
-		panic("fdrop: count %d", fp->f_count);
+	count = refcount_load(&fp->f_count);
+	if (count != 0)
+		panic("fdrop: fp %p count %d", fp, count);
+#endif
 	error = fo_close(fp, td);
 	atomic_subtract_int(&openfiles, 1);
 	crfree(fp->f_cred);


More information about the svn-src-all mailing list