Date: Mon, 11 Dec 2006 03:00:52 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 111432 for review Message-ID: <200612110300.kBB30qTW013681@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200612110300.kBB30qTW013681>