From owner-svn-src-all@FreeBSD.ORG Thu Dec 17 17:46:08 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D644D106568B; Thu, 17 Dec 2009 17:46:08 +0000 (UTC) (envelope-from gavin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C5B128FC19; Thu, 17 Dec 2009 17:46:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBHHk8Wu043394; Thu, 17 Dec 2009 17:46:08 GMT (envelope-from gavin@svn.freebsd.org) Received: (from gavin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBHHk8VM043392; Thu, 17 Dec 2009 17:46:08 GMT (envelope-from gavin@svn.freebsd.org) Message-Id: <200912171746.nBHHk8VM043392@svn.freebsd.org> From: Gavin Atkinson Date: Thu, 17 Dec 2009 17:46:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200637 - head/sys/dev/ciss X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2009 17:46:08 -0000 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); }