Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci ubsec(4): Prune dead branches. Assert session i...



details:   https://anonhg.NetBSD.org/src/rev/da892079cff7
branches:  trunk
changeset: 366330:da892079cff7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun May 22 11:38:43 2022 +0000

description:
ubsec(4): Prune dead branches.  Assert session id validity.

diffstat:

 sys/dev/pci/ubsec.c |  22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diffs (59 lines):

diff -r 67015ba60830 -r da892079cff7 sys/dev/pci/ubsec.c
--- a/sys/dev/pci/ubsec.c       Sun May 22 11:38:34 2022 +0000
+++ b/sys/dev/pci/ubsec.c       Sun May 22 11:38:43 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ubsec.c,v 1.57 2022/05/22 11:35:13 riastradh Exp $     */
+/*     $NetBSD: ubsec.c,v 1.58 2022/05/22 11:38:43 riastradh Exp $     */
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*     $OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$ */
 
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.57 2022/05/22 11:35:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.58 2022/05/22 11:38:43 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -955,18 +955,12 @@
 ubsec_newsession(void *arg, u_int32_t *sidp, struct cryptoini *cri)
 {
        struct cryptoini *c, *encini = NULL, *macini = NULL;
-       struct ubsec_softc *sc;
+       struct ubsec_softc *sc = arg;
        struct ubsec_session *ses = NULL;
        MD5_CTX md5ctx;
        SHA1_CTX sha1ctx;
        int i, sesn;
 
-       sc = arg;
-       KASSERT(sc != NULL /*, ("ubsec_newsession: null softc")*/);
-
-       if (sidp == NULL || cri == NULL || sc == NULL)
-               return (EINVAL);
-
        for (c = cri; c != NULL; c = c->cri_next) {
                if (c->cri_alg == CRYPTO_MD5_HMAC_96 ||
                    c->cri_alg == CRYPTO_SHA1_HMAC_96) {
@@ -1108,16 +1102,14 @@
 static int
 ubsec_freesession(void *arg, u_int64_t tid)
 {
-       struct ubsec_softc *sc;
+       struct ubsec_softc *sc = arg;
        int session;
        u_int32_t sid = ((u_int32_t) tid) & 0xffffffff;
 
-       sc = arg;
-       KASSERT(sc != NULL /*, ("ubsec_freesession: null softc")*/);
-
        session = UBSEC_SESSION(sid);
-       if (session >= sc->sc_nsessions)
-               return (EINVAL);
+       KASSERTMSG(session >= 0, "session=%d", session);
+       KASSERTMSG(session < sc->sc_nsessions, "session=%d nsessions=%d",
+           session, sc->sc_nsessions);
 
        memset(&sc->sc_sessions[session], 0, sizeof(sc->sc_sessions[session]));
        return (0);



Home | Main Index | Thread Index | Old Index