Module Name: src
Committed By: riastradh
Date: Sun May 22 11:38:26 UTC 2022
Modified Files:
src/sys/dev/marvell: mvcesa.c
Log Message:
mvcesa(4): Prune dead branches. Assert session id validity.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/marvell/mvcesa.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/marvell/mvcesa.c
diff -u src/sys/dev/marvell/mvcesa.c:1.4 src/sys/dev/marvell/mvcesa.c:1.5
--- src/sys/dev/marvell/mvcesa.c:1.4 Sun Dec 5 02:41:44 2021
+++ src/sys/dev/marvell/mvcesa.c Sun May 22 11:38:26 2022
@@ -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
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
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
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)