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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to