diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-09-03 10:13:45 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-09-03 10:13:45 +0000 |
commit | 31dfdcc554c0994b40195ad104ec0758fb122fcd (patch) | |
tree | 96cd19b69ac4c4d1707fc030d1b6673a993578c5 /sys/crypto | |
parent | b8d4a94a16af0cc7df1e8683da2317d3468ab248 (diff) |
do not screw up the reference counts
Diffstat (limited to 'sys/crypto')
-rw-r--r-- | sys/crypto/cryptodev.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/crypto/cryptodev.c b/sys/crypto/cryptodev.c index 098543619db..e37082e9e10 100644 --- a/sys/crypto/cryptodev.c +++ b/sys/crypto/cryptodev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.c,v 1.23 2001/08/28 12:20:43 ben Exp $ */ +/* $OpenBSD: cryptodev.c,v 1.24 2001/09/03 10:13:44 deraadt Exp $ */ /* * Copyright (c) 2001 Theo de Raadt @@ -108,7 +108,7 @@ struct csession *cseadd(struct fcrypt *, struct csession *); struct csession *csecreate(struct fcrypt *, u_int64_t, caddr_t, u_int64_t, caddr_t, u_int64_t, u_int32_t, u_int32_t, struct enc_xform *, struct auth_hash *); -void csefree(struct csession *); +int csefree(struct csession *); int crypto_op(struct csession *, struct crypt_op *, struct proc *); @@ -263,9 +263,8 @@ bail: cse = csefind(fcr, ses); if (cse == NULL) return (EINVAL); - error = crypto_freesession(cse->sid); csedelete(fcr, cse); - csefree(cse); + error = csefree(cse); break; case CIOCCRYPT: cop = (struct crypt_op *)data; @@ -472,7 +471,7 @@ cryptof_close(fp, p) while ((cse = TAILQ_FIRST(&fcr->csessions))) { TAILQ_REMOVE(&fcr->csessions, cse, next); - csefree(cse); + (void)csefree(cse); } FREE(fcr, M_XDATA); fp->f_data = NULL; @@ -624,13 +623,16 @@ csecreate(struct fcrypt *fcr, u_int64_t sid, caddr_t key, u_int64_t keylen, return (cse); } -void +int csefree(struct csession *cse) { + int error; + + error = crypto_freesession(cse->sid); if (cse->key) FREE(cse->key, M_XDATA); if (cse->mackey) FREE(cse->mackey, M_XDATA); - (void) crypto_freesession(cse->sid); FREE(cse, M_XDATA); + return (error); } |