From owner-svn-src-head@FreeBSD.ORG Thu Oct 14 23:26:09 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D3D8106564A; Thu, 14 Oct 2010 23:26:09 +0000 (UTC) (envelope-from mdf@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EFC0E8FC0C; Thu, 14 Oct 2010 23:26: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 o9ENQ8BZ041505; Thu, 14 Oct 2010 23:26:08 GMT (envelope-from mdf@svn.freebsd.org) Received: (from mdf@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9ENQ8bE041503; Thu, 14 Oct 2010 23:26:08 GMT (envelope-from mdf@svn.freebsd.org) Message-Id: <201010142326.o9ENQ8bE041503@svn.freebsd.org> From: Matthew D Fleming Date: Thu, 14 Oct 2010 23:26: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: r213882 - head/sys/dev/mps X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2010 23:26:09 -0000 Author: mdf Date: Thu Oct 14 23:26:08 2010 New Revision: 213882 URL: http://svn.freebsd.org/changeset/base/213882 Log: Fixes to mps_user_command(): - fix the leak of command struct on error - simplify the cleanup logic - EINPROGRESS is not a fatal error - buggy comment and error message Reviewed by: ken Modified: head/sys/dev/mps/mps_user.c Modified: head/sys/dev/mps/mps_user.c ============================================================================== --- head/sys/dev/mps/mps_user.c Thu Oct 14 22:45:14 2010 (r213881) +++ head/sys/dev/mps/mps_user.c Thu Oct 14 23:26:08 2010 (r213882) @@ -579,7 +579,7 @@ mps_user_command(struct mps_softc *sc, s MPI2_REQUEST_HEADER *hdr; MPI2_DEFAULT_REPLY *rpl; void *buf = NULL; - struct mps_command *cm; + struct mps_command *cm = NULL; int err = 0; int sz; @@ -631,11 +631,12 @@ mps_user_command(struct mps_softc *sc, s mps_lock(sc); err = mps_map_command(sc, cm); - if (err != 0) { - mps_printf(sc, "mps_user_command: request timed out\n"); + if (err != 0 && err != EINPROGRESS) { + mps_printf(sc, "%s: invalid request: error %d\n", + __func__, err); goto Ret; } - msleep(cm, &sc->mps_mtx, 0, "mpsuser", 0); /* 30 seconds */ + msleep(cm, &sc->mps_mtx, 0, "mpsuser", 0); rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply; sz = rpl->MsgLength * 4; @@ -652,22 +653,14 @@ mps_user_command(struct mps_softc *sc, s copyout(rpl, cmd->rpl, sz); if (buf != NULL) copyout(buf, cmd->buf, cmd->len); - mps_lock(sc); - mps_dprint(sc, MPS_INFO, "mps_user_command: reply size %d\n", sz ); - mps_free_command(sc, cm); -Ret: - mps_unlock(sc); - if (buf != NULL) - free(buf, M_MPSUSER); - return (err); - RetFreeUnlocked: mps_lock(sc); - mps_free_command(sc, cm); + if (cm != NULL) + mps_free_command(sc, cm); +Ret: mps_unlock(sc); - if (buf != NULL) free(buf, M_MPSUSER); return (err);