mvcesa(4): Prune dead branches. Assert session id validity.
This commit is contained in:
parent
6064b94a93
commit
4b175f2550
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue