Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/opencrypto opencrypto: Make crypto_freesession return void.



details:   https://anonhg.NetBSD.org/src/rev/419fe99964eb
branches:  trunk
changeset: 366336:419fe99964eb
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun May 22 11:39:37 2022 +0000

description:
opencrypto: Make crypto_freesession return void.

No callers use the return value.  It is not sensible to allow this to
fail.

diffstat:

 share/man/man9/opencrypto.9 |   7 +++----
 sys/netipsec/xform_ah.c     |   6 +++---
 sys/netipsec/xform_ipcomp.c |   6 +++---
 sys/opencrypto/crypto.c     |  12 +++++-------
 sys/opencrypto/cryptodev.c  |   8 ++++----
 sys/opencrypto/cryptodev.h  |   4 ++--
 6 files changed, 20 insertions(+), 23 deletions(-)

diffs (181 lines):

diff -r 3638d72eebee -r 419fe99964eb share/man/man9/opencrypto.9
--- a/share/man/man9/opencrypto.9       Sun May 22 11:39:26 2022 +0000
+++ b/share/man/man9/opencrypto.9       Sun May 22 11:39:37 2022 +0000
@@ -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@localhost)
 .\"
@@ -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 @@
 .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.
diff -r 3638d72eebee -r 419fe99964eb sys/netipsec/xform_ah.c
--- a/sys/netipsec/xform_ah.c   Sun May 22 11:39:26 2022 +0000
+++ b/sys/netipsec/xform_ah.c   Sun May 22 11:39:37 2022 +0000
@@ -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 @@
                    _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;
diff -r 3638d72eebee -r 419fe99964eb sys/netipsec/xform_ipcomp.c
--- a/sys/netipsec/xform_ipcomp.c       Sun May 22 11:39:26 2022 +0000
+++ b/sys/netipsec/xform_ipcomp.c       Sun May 22 11:39:37 2022 +0000
@@ -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 @@
 ipcomp_zeroize(struct secasvar *sav)
 {
 
-       (void)crypto_freesession(sav->tdb_cryptoid);
+       crypto_freesession(sav->tdb_cryptoid);
        sav->tdb_cryptoid = 0;
 }
 
diff -r 3638d72eebee -r 419fe99964eb sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Sun May 22 11:39:26 2022 +0000
+++ b/sys/opencrypto/crypto.c   Sun May 22 11:39:37 2022 +0000
@@ -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 @@
  * 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 @@
 
        /* 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_driver_clear(cap);
 
        crypto_driver_unlock(cap);
-       return err;
 }
 
 static bool
diff -r 3638d72eebee -r 419fe99964eb sys/opencrypto/cryptodev.c
--- a/sys/opencrypto/cryptodev.c        Sun May 22 11:39:26 2022 +0000
+++ b/sys/opencrypto/cryptodev.c        Sun May 22 11:39:37 2022 +0000
@@ -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 @@
 {
        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)
diff -r 3638d72eebee -r 419fe99964eb sys/opencrypto/cryptodev.h
--- a/sys/opencrypto/cryptodev.h        Sun May 22 11:39:26 2022 +0000
+++ b/sys/opencrypto/cryptodev.h        Sun May 22 11:39:37 2022 +0000
@@ -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 @@
 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,



Home | Main Index | Thread Index | Old Index