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.
This commit is contained in:
Warner Losh 2020-02-14 00:13:23 +00:00
parent 1f4fa9156d
commit 2100c6d00f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=357897

View file

@ -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;