diff options
| author | riastradh <riastradh@NetBSD.org> | 2022-05-22 11:38:26 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2022-05-22 11:38:26 +0000 |
| commit | 7292bdd4eedaf36a902caa16c6aef46892f479c0 (patch) | |
| tree | 2b03b9544b2eee1abb7fbbd8cfe877da7aa7cfba /sys/dev | |
| parent | 9bf49373ad731ef498446b5a4255e71c7e2346f2 (diff) | |
mvcesa(4): Prune dead branches. Assert session id validity.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/marvell/mvcesa.c | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/sys/dev/marvell/mvcesa.c b/sys/dev/marvell/mvcesa.c index 973dcb39f57..f0b3b206f43 100644 --- a/sys/dev/marvell/mvcesa.c +++ b/sys/dev/marvell/mvcesa.c @@ -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 @@ mvcesa_freesession(void *arg, u_int64_t tid) 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 @@ mvcesa_freesession(void *arg, u_int64_t tid) 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 @@ mvcesa_process(void *arg, struct cryptop *crp, int hint) 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) |
