From owner-svn-src-all@FreeBSD.ORG Wed Sep 16 23:17:22 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 B7FDB106566C; Wed, 16 Sep 2009 23:17:22 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A82B58FC19; Wed, 16 Sep 2009 23:17:22 +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 n8GNHMt5038702; Wed, 16 Sep 2009 23:17:22 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8GNHMFs038700; Wed, 16 Sep 2009 23:17:22 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <200909162317.n8GNHMFs038700@svn.freebsd.org> From: Scott Long Date: Wed, 16 Sep 2009 23:17:22 +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: r197262 - 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: Wed, 16 Sep 2009 23:17:22 -0000 Author: scottl Date: Wed Sep 16 23:17:22 2009 New Revision: 197262 URL: http://svn.freebsd.org/changeset/base/197262 Log: Fix locking around copyout() operations. Modified: head/sys/dev/ciss/ciss.c Modified: head/sys/dev/ciss/ciss.c ============================================================================== --- head/sys/dev/ciss/ciss.c Wed Sep 16 23:10:10 2009 (r197261) +++ head/sys/dev/ciss/ciss.c Wed Sep 16 23:17:22 2009 (r197262) @@ -2567,15 +2567,16 @@ ciss_user_command(struct ciss_softc *sc, /* * Allocate an in-kernel databuffer if required, copy in user data. */ + mtx_unlock(&sc->ciss_mtx); cr->cr_length = ioc->buf_size; if (ioc->buf_size > 0) { if ((cr->cr_data = malloc(ioc->buf_size, CISS_MALLOC_CLASS, M_NOWAIT)) == NULL) { error = ENOMEM; - goto out; + goto out_unlocked; } if ((error = copyin(ioc->buf, cr->cr_data, ioc->buf_size))) { debug(0, "copyin: bad data buffer %p/%d", ioc->buf, ioc->buf_size); - goto out; + goto out_unlocked; } } @@ -2586,6 +2587,7 @@ ciss_user_command(struct ciss_softc *sc, bcopy(&ioc->Request, &cc->cdb, sizeof(cc->cdb)); /* XXX anything else to populate here? */ + mtx_lock(&sc->ciss_mtx); /* * Run the command. @@ -2606,15 +2608,19 @@ ciss_user_command(struct ciss_softc *sc, * Copy the results back to the user. */ bcopy(ce, &ioc->error_info, sizeof(*ce)); + mtx_unlock(&sc->ciss_mtx); if ((ioc->buf_size > 0) && (error = copyout(cr->cr_data, ioc->buf, ioc->buf_size))) { debug(0, "copyout: bad data buffer %p/%d", ioc->buf, ioc->buf_size); - goto out; + goto out_unlocked; } /* done OK */ error = 0; +out_unlocked: + mtx_lock(&sc->ciss_mtx); + out: if ((cr != NULL) && (cr->cr_data != NULL)) free(cr->cr_data, CISS_MALLOC_CLASS);