From owner-svn-src-stable-7@FreeBSD.ORG Wed May 19 19:45:17 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B10C1065670; Wed, 19 May 2010 19:45:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8B5CA8FC0A; Wed, 19 May 2010 19:45:17 +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 o4JJjHet070018; Wed, 19 May 2010 19:45:17 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4JJjH8L070016; Wed, 19 May 2010 19:45:17 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201005191945.o4JJjH8L070016@svn.freebsd.org> From: John Baldwin Date: Wed, 19 May 2010 19:45:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208310 - stable/7/sys/dev/ciss X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2010 19:45:17 -0000 Author: jhb Date: Wed May 19 19:45:17 2010 New Revision: 208310 URL: http://svn.freebsd.org/changeset/base/208310 Log: MFC 200637,207335: - Don't panic due to unlocking an unowned mutex if we fail during attach. - Initialize the callout structure earlier in attach before calling any routines that can fail since ciss_free() always tries to stop and drain the callout. Modified: stable/7/sys/dev/ciss/ciss.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/ciss/ciss.c ============================================================================== --- stable/7/sys/dev/ciss/ciss.c Wed May 19 19:44:00 2010 (r208309) +++ stable/7/sys/dev/ciss/ciss.c Wed May 19 19:45:17 2010 (r208310) @@ -394,6 +394,8 @@ ciss_attach(device_t dev) sc = device_get_softc(dev); sc->ciss_dev = dev; + mtx_init(&sc->ciss_mtx, "cissmtx", NULL, MTX_DEF); + callout_init_mtx(&sc->ciss_periodic, &sc->ciss_mtx, 0); /* * Work out adapter type. @@ -428,8 +430,6 @@ ciss_attach(device_t dev) ciss_initq_busy(sc); ciss_initq_complete(sc); ciss_initq_notify(sc); - mtx_init(&sc->ciss_mtx, "cissmtx", NULL, MTX_DEF); - callout_init_mtx(&sc->ciss_periodic, &sc->ciss_mtx, 0); /* * Initalize device sysctls. @@ -494,8 +494,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); }