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.
This commit is contained in:
Warner Losh 2020-10-06 23:33:56 +00:00
parent 6debfd4b13
commit a1975719dd

View File

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