Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/marvell mvxpsec(4): Prune dead branches. Assert ses...



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

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

diffstat:

 sys/dev/marvell/mvxpsec.c |  20 ++++++--------------
 1 files changed, 6 insertions(+), 14 deletions(-)

diffs (36 lines):

diff -r da892079cff7 -r 0215f475f349 sys/dev/marvell/mvxpsec.c
--- a/sys/dev/marvell/mvxpsec.c Sun May 22 11:38:43 2022 +0000
+++ b/sys/dev/marvell/mvxpsec.c Sun May 22 11:38:51 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mvxpsec.c,v 1.14 2022/04/12 21:05:37 andvar Exp $      */
+/*     $NetBSD: mvxpsec.c,v 1.15 2022/05/22 11:38:51 riastradh Exp $   */
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
  * All rights reserved.
@@ -2029,21 +2029,13 @@
        uint32_t sid = ((uint32_t)tid) & 0xffffffff;
 
        session = MVXPSEC_SESSION(sid);
-       if (session < 0 || session >= MVXPSEC_MAX_SESSIONS) {
-               log(LOG_ERR, "%s: invalid session (id:%u)\n",
-                   __func__, session);
-               return EINVAL;
-       }
+       KASSERTMSG(session >= 0, "session=%d", session);
+       KASSERTMSG(session < MVXPSEC_MAX_SESSIONS, "session=%d max=%d",
+           session, MVXPSEC_MAX_SESSIONS);
 
        mutex_enter(&sc->sc_session_mtx);
-       if ( (mv_s = sc->sc_sessions[session]) == NULL) {
-               mutex_exit(&sc->sc_session_mtx);
-#ifdef DEBUG
-               log(LOG_DEBUG, "%s: session %d already inactivated\n",
-                   __func__, session);
-#endif
-               return ENOENT;
-       }
+       mv_s = sc->sc_sessions[session];
+       KASSERT(mv_s != NULL);
        MVXPSEC_PRINTF(MVXPSEC_DEBUG_OPENCRYPTO,
            "%s: inactivate session %d\n", __func__, session);
 



Home | Main Index | Thread Index | Old Index