diff options
author | pjd <pjd@FreeBSD.org> | 2008-08-09 19:48:59 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2008-08-09 19:48:59 +0000 |
commit | c2715b68b618eb73d1e2b53a50958e4a5c660096 (patch) | |
tree | c816f2f1d9850cbac3868bf017ca67b3e1b52e9d /sys/crypto | |
parent | e3f8d38bb08a6c460df36e864156c00cc67756f2 (diff) | |
download | FreeBSD-src-c2715b68b618eb73d1e2b53a50958e4a5c660096.zip FreeBSD-src-c2715b68b618eb73d1e2b53a50958e4a5c660096.tar.gz |
- Fix freeing session on newsession failure.
- Update copyright years.
Diffstat (limited to 'sys/crypto')
-rw-r--r-- | sys/crypto/via/padlock.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/sys/crypto/via/padlock.c b/sys/crypto/via/padlock.c index a1d2da8..dddae15 100644 --- a/sys/crypto/via/padlock.c +++ b/sys/crypto/via/padlock.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> + * Copyright (c) 2005-2008 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,8 @@ struct padlock_softc { static int padlock_newsession(device_t, uint32_t *sidp, struct cryptoini *cri); static int padlock_freesession(device_t, uint64_t tid); +static void padlock_freesession_one(struct padlock_softc *sc, + struct padlock_session *ses, int locked); static int padlock_process(device_t, struct cryptop *crp, int hint __unused); MALLOC_DEFINE(M_PADLOCK, "padlock_data", "PadLock Data"); @@ -234,14 +236,14 @@ padlock_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri) error = padlock_cipher_setup(ses, encini); if (error != 0) { - padlock_freesession(NULL, ses->ses_id); + padlock_freesession_one(sc, ses, 0); return (error); } if (macini != NULL) { error = padlock_hash_setup(ses, macini); if (error != 0) { - padlock_freesession(NULL, ses->ses_id); + padlock_freesession_one(sc, ses, 0); return (error); } } @@ -250,6 +252,24 @@ padlock_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri) return (0); } +static void +padlock_freesession_one(struct padlock_softc *sc, struct padlock_session *ses, + int locked) +{ + uint32_t sid = ses->ses_id; + + if (!locked) + rw_wlock(&sc->sc_sessions_lock); + TAILQ_REMOVE(&sc->sc_sessions, ses, ses_next); + padlock_hash_free(ses); + bzero(ses, sizeof(*ses)); + ses->ses_used = 0; + ses->ses_id = sid; + TAILQ_INSERT_HEAD(&sc->sc_sessions, ses, ses_next); + if (!locked) + rw_wunlock(&sc->sc_sessions_lock); +} + static int padlock_freesession(device_t dev, uint64_t tid) { @@ -267,12 +287,7 @@ padlock_freesession(device_t dev, uint64_t tid) rw_wunlock(&sc->sc_sessions_lock); return (EINVAL); } - TAILQ_REMOVE(&sc->sc_sessions, ses, ses_next); - padlock_hash_free(ses); - bzero(ses, sizeof(*ses)); - ses->ses_used = 0; - ses->ses_id = sid; - TAILQ_INSERT_HEAD(&sc->sc_sessions, ses, ses_next); + padlock_freesession_one(sc, ses, 1); rw_wunlock(&sc->sc_sessions_lock); return (0); } |