svn commit: r200637 - head/sys/dev/ciss

Gavin Atkinson gavin at FreeBSD.org
Thu Dec 17 17:46:08 UTC 2009


Author: gavin
Date: Thu Dec 17 17:46:08 2009
New Revision: 200637
URL: http://svn.freebsd.org/changeset/base/200637

Log:
  Don't panic due to unlocking an unowned mutex if we fail during attach.
  
  PR:		kern/139053
  Reviewed by:	scottl
  Approved by:	ed (mentor)
  MFC after:	2 weeks

Modified:
  head/sys/dev/ciss/ciss.c

Modified: head/sys/dev/ciss/ciss.c
==============================================================================
--- head/sys/dev/ciss/ciss.c	Thu Dec 17 17:44:34 2009	(r200636)
+++ head/sys/dev/ciss/ciss.c	Thu Dec 17 17:46:08 2009	(r200637)
@@ -418,6 +418,7 @@ ciss_attach(device_t dev)
 
     sc = device_get_softc(dev);
     sc->ciss_dev = dev;
+    mtx_init(&sc->ciss_mtx, "cissmtx", NULL, MTX_DEF);
 
     /*
      * Do PCI-specific init.
@@ -430,7 +431,6 @@ ciss_attach(device_t dev)
      */
     ciss_initq_free(sc);
     ciss_initq_notify(sc);
-    mtx_init(&sc->ciss_mtx, "cissmtx", NULL, MTX_DEF);
     callout_init_mtx(&sc->ciss_periodic, &sc->ciss_mtx, 0);
 
     /*
@@ -496,8 +496,11 @@ ciss_attach(device_t dev)
 
     error = 0;
  out:
-    if (error != 0)
+    if (error != 0) {
+	/* ciss_free() expects the mutex to be held */
+	mtx_lock(&sc->ciss_mtx);
 	ciss_free(sc);
+    }
     return(error);
 }
 


More information about the svn-src-all mailing list