kernel - Split an assertion in the sysref code to make it MPSAFE
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 21 Dec 2009 16:13:47 +0000 (08:13 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 21 Dec 2009 16:13:47 +0000 (08:13 -0800)
* An assertion in the sysref code was not MPSAFE.  Test SRF_ALLOCATED
  after we have determined that the object is completely free.

sys/kern/kern_sysref.c

index d2b17e6..93b84fd 100644 (file)
@@ -334,9 +334,9 @@ _sysref_put(struct sysref *sr)
                         * If SRF_SYSIDUSED is not set just objcache_put() the
                         * resource, otherwise objcache_dtor() the resource.
                         */
-                       KKASSERT(count == -0x40000000 &&
-                                (sr->flags & SRF_ALLOCATED));
+                       KKASSERT(count == -0x40000000);
                        if (atomic_cmpset_int(&sr->refcnt, count, 0)) {
+                               KKASSERT(sr->flags & SRF_ALLOCATED);
                                data = (char *)sr - sr->srclass->offset;
                                if (sr->flags & SRF_SYSIDUSED)
                                        objcache_dtor(sr->srclass->oc, data);