From owner-p4-projects@FreeBSD.ORG Mon Dec 11 03:00:52 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BC7BC16A417; Mon, 11 Dec 2006 03:00:52 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9752A16A412 for ; Mon, 11 Dec 2006 03:00:52 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E73343CAE for ; Mon, 11 Dec 2006 02:59:38 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kBB30qEY013684 for ; Mon, 11 Dec 2006 03:00:52 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kBB30qTW013681 for perforce@freebsd.org; Mon, 11 Dec 2006 03:00:52 GMT (envelope-from sam@freebsd.org) Date: Mon, 11 Dec 2006 03:00:52 GMT Message-Id: <200612110300.kBB30qTW013681@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 111432 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 03:00:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=111432 Change 111432 by sam@sam_ebb on 2006/12/11 03:00:00 err, it helps to lock this stuff Affected files ... .. //depot/projects/crypto/sys/dev/hifn/hifn7751.c#10 edit Differences ... ==== //depot/projects/crypto/sys/dev/hifn/hifn7751.c#10 (text+ko) ==== @@ -2345,11 +2345,14 @@ if (sidp == NULL || cri == NULL || sc == NULL) return (EINVAL); + HIFN_LOCK(sc); if (sc->sc_sessions == NULL) { ses = sc->sc_sessions = (struct hifn_session *)malloc( sizeof(*ses), M_DEVBUF, M_NOWAIT); - if (ses == NULL) + if (ses == NULL) { + HIFN_UNLOCK(sc); return (ENOMEM); + } sesn = 0; sc->sc_nsessions = 1; } else { @@ -2364,8 +2367,10 @@ sesn = sc->sc_nsessions; ses = (struct hifn_session *)malloc((sesn + 1) * sizeof(*ses), M_DEVBUF, M_NOWAIT); - if (ses == NULL) + if (ses == NULL) { + HIFN_UNLOCK(sc); return (ENOMEM); + } bcopy(sc->sc_sessions, ses, sesn * sizeof(*ses)); bzero(sc->sc_sessions, sesn * sizeof(*ses)); free(sc->sc_sessions, M_DEVBUF); @@ -2374,6 +2379,8 @@ sc->sc_nsessions++; } } + HIFN_UNLOCK(sc); + bzero(ses, sizeof(*ses)); ses->hs_used = 1; @@ -2434,19 +2441,23 @@ hifn_freesession(device_t dev, u_int64_t tid) { struct hifn_softc *sc = device_get_softc(dev); - int session; + int session, error; u_int32_t sid = CRYPTO_SESID2LID(tid); KASSERT(sc != NULL, ("hifn_freesession: null softc")); if (sc == NULL) return (EINVAL); + HIFN_LOCK(sc); session = HIFN_SESSION(sid); - if (session >= sc->sc_nsessions) - return (EINVAL); + if (session < sc->sc_nsessions) { + bzero(&sc->sc_sessions[session], sizeof(struct hifn_session)); + error = 0; + } else + error = EINVAL; + HIFN_UNLOCK(sc); - bzero(&sc->sc_sessions[session], sizeof(sc->sc_sessions[session])); - return (0); + return (error); } static int