opencrypto: Make crypto_freesession return void.

No callers use the return value.  It is not sensible to allow this to
fail.
This commit is contained in:
riastradh 2022-05-22 11:39:37 +00:00
parent ee55792f15
commit a1f5e1f25c
6 changed files with 20 additions and 23 deletions

View File

@ -1,5 +1,5 @@
.\" $OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
.\" $NetBSD: opencrypto.9,v 1.19 2022/05/22 11:39:26 riastradh Exp $
.\" $NetBSD: opencrypto.9,v 1.20 2022/05/22 11:39:37 riastradh Exp $
.\"
.\" The author of this man page is Angelos D. Keromytis (angelos@cis.upenn.edu)
.\"
@ -55,7 +55,7 @@
.Fn crypto_kdone "struct cryptkop *"
.Ft int
.Fn crypto_newsession "u_int64_t *" "struct cryptoini *" "int"
.Ft int
.Ft void
.Fn crypto_freesession "u_int64_t"
.Ft int
.Fn crypto_dispatch "struct cryptop *"
@ -642,9 +642,8 @@ routine should invoke
.Fn crypto_register ,
.Fn crypto_kregister ,
.Fn crypto_unregister ,
.Fn crypto_newsession ,
and
.Fn crypto_freesession
.Fn crypto_newsession
return 0 on success, or an error code on failure.
.Fn crypto_get_driverid
returns a non-negative value on error, and \-1 on failure.

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_ah.c,v 1.111 2022/05/22 11:39:08 riastradh Exp $ */
/* $NetBSD: xform_ah.c,v 1.112 2022/05/22 11:39:37 riastradh Exp $ */
/* $FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
/*
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.111 2022/05/22 11:39:08 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.112 2022/05/22 11:39:37 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_inet.h"
@ -273,7 +273,7 @@ ah_zeroize(struct secasvar *sav)
_KEYLEN(sav->key_auth));
}
(void)crypto_freesession(sav->tdb_cryptoid);
crypto_freesession(sav->tdb_cryptoid);
sav->tdb_cryptoid = 0;
sav->tdb_authalgxform = NULL;
sav->tdb_xform = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: xform_ipcomp.c,v 1.71 2022/05/22 11:39:08 riastradh Exp $ */
/* $NetBSD: xform_ipcomp.c,v 1.72 2022/05/22 11:39:37 riastradh Exp $ */
/* $FreeBSD: xform_ipcomp.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.71 2022/05/22 11:39:08 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.72 2022/05/22 11:39:37 riastradh Exp $");
/* IP payload compression protocol (IPComp), see RFC 2393 */
#if defined(_KERNEL_OPT)
@ -128,7 +128,7 @@ static void
ipcomp_zeroize(struct secasvar *sav)
{
(void)crypto_freesession(sav->tdb_cryptoid);
crypto_freesession(sav->tdb_cryptoid);
sav->tdb_cryptoid = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: crypto.c,v 1.124 2022/05/22 11:39:27 riastradh Exp $ */
/* $NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $ */
/* $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $ */
/* $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
@ -53,7 +53,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.124 2022/05/22 11:39:27 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $");
#include <sys/param.h>
#include <sys/reboot.h>
@ -852,11 +852,10 @@ crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard)
* Delete an existing session (or a reserved session on an unregistered
* driver).
*/
int
void
crypto_freesession(u_int64_t sid)
{
struct cryptocap *cap;
int err = 0;
/*
* crypto_newsession never returns 0 as a sid (by virtue of
@ -871,8 +870,8 @@ crypto_freesession(u_int64_t sid)
/* Determine two IDs. */
cap = crypto_checkdriver_lock(CRYPTO_SESID2HID(sid));
if (cap == NULL)
return ENOENT;
if (cap == NULL) /* XXX should assert; need to audit callers */
return;
if (cap->cc_sessions)
(cap->cc_sessions)--;
@ -889,7 +888,6 @@ crypto_freesession(u_int64_t sid)
crypto_driver_clear(cap);
crypto_driver_unlock(cap);
return err;
}
static bool

View File

@ -1,4 +1,4 @@
/* $NetBSD: cryptodev.c,v 1.119 2022/05/22 11:39:17 riastradh Exp $ */
/* $NetBSD: cryptodev.c,v 1.120 2022/05/22 11:39:37 riastradh Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.119 2022/05/22 11:39:17 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.120 2022/05/22 11:39:37 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1019,8 +1019,8 @@ csefree(struct csession *cse)
{
int error;
error = crypto_freesession(cse->sid);
KASSERTMSG(error == 0, "error=%d", error);
crypto_freesession(cse->sid);
error = 0;
if (cse->key)
free(cse->key, M_XDATA);
if (cse->mackey)

View File

@ -1,4 +1,4 @@
/* $NetBSD: cryptodev.h,v 1.47 2022/05/22 11:39:27 riastradh Exp $ */
/* $NetBSD: cryptodev.h,v 1.48 2022/05/22 11:39:37 riastradh Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.6 2003/07/02 17:04:50 sam Exp $ */
/* $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $ */
@ -596,7 +596,7 @@ struct cryptocap {
MALLOC_DECLARE(M_CRYPTO_DATA);
extern int crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int hard);
extern int crypto_freesession(u_int64_t sid);
extern void crypto_freesession(u_int64_t sid);
extern int32_t crypto_get_driverid(u_int32_t flags);
extern int crypto_register(u_int32_t driverid, int alg, u_int16_t maxoplen,
u_int32_t flags,