Module Name:    src
Committed By:   riastradh
Date:           Sun May 22 11:38:19 UTC 2022

Modified Files:
        src/sys/arch/x86/x86: via_padlock.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/x86/x86/via_padlock.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/arch/x86/x86/via_padlock.c
diff -u src/sys/arch/x86/x86/via_padlock.c:1.33 src/sys/arch/x86/x86/via_padlock.c:1.34
--- src/sys/arch/x86/x86/via_padlock.c:1.33	Sun May 22 11:38:02 2022
+++ src/sys/arch/x86/x86/via_padlock.c	Sun May 22 11:38:19 2022
@@ -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 @@ via_padlock_crypto_newsession(void *arg,
 	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 @@ via_padlock_crypto_freesession(void *arg
 	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;

Reply via email to