Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/marvell mvcesa(4): Prune dead branches. Assert sess...



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

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

diffstat:

 sys/dev/marvell/mvcesa.c |  28 ++++++++--------------------
 1 files changed, 8 insertions(+), 20 deletions(-)

diffs (65 lines):

diff -r e9adb86c2ecb -r 5f0f53b37b5b sys/dev/marvell/mvcesa.c
--- a/sys/dev/marvell/mvcesa.c  Sun May 22 11:38:19 2022 +0000
+++ b/sys/dev/marvell/mvcesa.c  Sun May 22 11:38:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mvcesa.c,v 1.4 2021/12/05 02:41:44 msaitoh Exp $       */
+/*     $NetBSD: mvcesa.c,v 1.5 2022/05/22 11:38:26 riastradh Exp $     */
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvcesa.c,v 1.4 2021/12/05 02:41:44 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvcesa.c,v 1.5 2022/05/22 11:38:26 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -332,11 +332,10 @@
        int session;
        uint32_t sid = ((uint32_t)tid) & 0xffffffff;
 
-       KASSERT(sc != NULL /*, ("mvcesa_freesession: null softc")*/);
-
        session = MVCESA_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);
@@ -345,7 +344,7 @@
 static int
 mvcesa_process(void *arg, struct cryptop *crp, int hint)
 {
-       struct mvcesa_softc *sc = (struct mvcesa_softc *)arg;
+       struct mvcesa_softc *sc = arg;
        struct mvcesa_session *ses;
        struct cryptodesc *crd;
        struct mbuf *m = NULL;
@@ -353,20 +352,9 @@
        int session;
        char *buf = NULL;
 
-       KASSERT(sc != NULL /*, ("mvcesa_process: null softc")*/);
-
-       if (crp == NULL)
-               return EINVAL;
-       if (crp->crp_callback == NULL || sc == NULL) {
-               crp->crp_etype = EINVAL;
-               goto done;
-       }
-
        session = MVCESA_SESSION(crp->crp_sid);
-       if (session >= sc->sc_nsessions) {
-               crp->crp_etype = ENOENT;
-               goto done;
-       }
+       KASSERTMSG(session < sc->sc_nsessions, "session=%d nsessions=%d",
+           session, sc->sc_nsessions);
        ses = &sc->sc_sessions[session];
 
        if (crp->crp_flags & CRYPTO_F_IMBUF)



Home | Main Index | Thread Index | Old Index