Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Oct 2020 23:33:56 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r366504 - head/sys/cam
Message-ID:  <202010062333.096NXuVp082757@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Oct  6 23:33:56 2020
New Revision: 366504
URL: https://svnweb.freebsd.org/changeset/base/366504

Log:
  cam: Assert we have a reference when freeing sim
  
  Before we decrement refcount to sleep on the sim, assert that the
  refcount >= 1. If it were 0 here, we'd never wake up.

Modified:
  head/sys/cam/cam_sim.c

Modified: head/sys/cam/cam_sim.c
==============================================================================
--- head/sys/cam/cam_sim.c	Tue Oct  6 23:16:56 2020	(r366503)
+++ head/sys/cam/cam_sim.c	Tue Oct  6 23:33:56 2020	(r366504)
@@ -134,6 +134,7 @@ cam_sim_free(struct cam_sim *sim, int free_devq)
 		mtx = sim->mtx;
 		mtx_assert(mtx, MA_OWNED);
 	}
+	KASSERT(sim->refcount >= 1, ("sim->refcount >= 1"));
 	sim->refcount--;
 	if (sim->refcount > 0) {
 		error = msleep(sim, mtx, PRIBIO, "simfree", 0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010062333.096NXuVp082757>