svn commit: r357897 - head/sys/cam

Warner Losh imp at FreeBSD.org
Fri Feb 14 00:13:24 UTC 2020


Author: imp
Date: Fri Feb 14 00:13:23 2020
New Revision: 357897
URL: https://svnweb.freebsd.org/changeset/base/357897

Log:
  Add a KASSERT that there's no outstanding CCBs when we call camperiphfree. We
  know that if there are any outstanding CCBs, then when they dereference the path
  that's freed at the bottom of camperiphfree there will be some flavor of
  panic. This moves that eventual panic to a traceback of when we free the last
  reference on the device, which is earlier but may not be early enough.

Modified:
  head/sys/cam/cam_periph.c

Modified: head/sys/cam/cam_periph.c
==============================================================================
--- head/sys/cam/cam_periph.c	Fri Feb 14 00:12:59 2020	(r357896)
+++ head/sys/cam/cam_periph.c	Fri Feb 14 00:13:23 2020	(r357897)
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_periph.h>
 #include <cam/cam_debug.h>
 #include <cam/cam_sim.h>
+#include <cam/cam_xpt_internal.h>	/* For KASSERTs only */
 
 #include <cam/scsi/scsi_all.h>
 #include <cam/scsi/scsi_message.h>
@@ -681,6 +682,10 @@ camperiphfree(struct cam_periph *periph)
 	cam_periph_assert(periph, MA_OWNED);
 	KASSERT(periph->periph_allocating == 0, ("%s%d: freed while allocating",
 	    periph->periph_name, periph->unit_number));
+	KASSERT(periph->path->device->ccbq.dev_active == 0,
+	    ("%s%d: freed with %d active CCBs\n",
+		periph->periph_name, periph->unit_number,
+		periph->path->device->ccbq.dev_active));
 	for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
 		if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
 			break;


More information about the svn-src-all mailing list