Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 padlock(4): Prune dead branches. Assert se...



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

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

diffstat:

 sys/arch/x86/x86/via_padlock.c |  17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diffs (47 lines):

diff -r aa282e6f3c8b -r e9adb86c2ecb sys/arch/x86/x86/via_padlock.c
--- a/sys/arch/x86/x86/via_padlock.c    Sun May 22 11:38:12 2022 +0000
+++ b/sys/arch/x86/x86/via_padlock.c    Sun May 22 11:38:19 2022 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $     */
-/*     $NetBSD: via_padlock.c,v 1.33 2022/05/22 11:38:02 riastradh Exp $ */
+/*     $NetBSD: via_padlock.c,v 1.34 2022/05/22 11:38:19 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2003 Jason Wright
@@ -20,7 +20,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.33 2022/05/22 11:38:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.34 2022/05/22 11:38:19 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -135,10 +135,6 @@
        struct swcr_data *swd;
        int sesn, i, cw0;
 
-       KASSERT(sc != NULL /*, ("via_padlock_crypto_freesession: null softc")*/);
-       if (sc == NULL || sidp == NULL || cri == NULL)
-               return (EINVAL);
-
        if (sc->sc_sessions == NULL) {
                ses = sc->sc_sessions = malloc(sizeof(*ses), M_DEVBUF,
                    M_NOWAIT);
@@ -311,13 +307,10 @@
        int sesn;
        uint32_t sid = ((uint32_t)tid) & 0xffffffff;
 
-       KASSERT(sc != NULL /*, ("via_padlock_crypto_freesession: null softc")*/);
-       if (sc == NULL)
-               return (EINVAL);
-
        sesn = VIAC3_SESSION(sid);
-       if (sesn >= sc->sc_nsessions)
-               return (EINVAL);
+       KASSERTMSG(sesn >= 0, "sesn=%d", sesn);
+       KASSERTMSG(sesn < sc->sc_nsessions, "sesn=%d nsessions=%d",
+           sesn, sc->sc_nsessions);
 
        if (sc->sc_sessions[sesn].swd) {
                swd = sc->sc_sessions[sesn].swd;



Home | Main Index | Thread Index | Old Index