Source-Changes-HG archive

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

[src/trunk]: src/sys/opencrypto add some assertion. tested by ATF net/ipsec/ ...



details:   https://anonhg.NetBSD.org/src/rev/7e68d002eb64
branches:  trunk
changeset: 823671:7e68d002eb64
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Tue May 02 03:17:43 2017 +0000

description:
add some assertion. tested by ATF net/ipsec/ and crypto/.

diffstat:

 sys/opencrypto/crypto.c |  24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diffs (88 lines):

diff -r 83fed825b982 -r 7e68d002eb64 sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Mon May 01 23:33:07 2017 +0000
+++ b/sys/opencrypto/crypto.c   Tue May 02 03:17:43 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.58 2017/04/26 03:29:36 knakahara Exp $ */
+/*     $NetBSD: crypto.c,v 1.59 2017/05/02 03:17:43 knakahara Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $   */
 /*     $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
 
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.58 2017/04/26 03:29:36 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.59 2017/05/02 03:17:43 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -739,9 +739,13 @@
 int
 crypto_dispatch(struct cryptop *crp)
 {
-       u_int32_t hid = CRYPTO_SESID2HID(crp->crp_sid);
+       u_int32_t hid;
        int result;
 
+       KASSERT(crp != NULL);
+
+       hid = CRYPTO_SESID2HID(crp->crp_sid);
+
        mutex_spin_enter(&crypto_q_mtx);
        DPRINTF(("crypto_dispatch: crp %p, alg %d\n",
                crp, crp->crp_desc->crd_alg));
@@ -825,6 +829,8 @@
        struct cryptocap *cap;
        int result;
 
+       KASSERT(krp != NULL);
+
        mutex_spin_enter(&crypto_q_mtx);
        cryptostats.cs_kops++;
 
@@ -873,9 +879,9 @@
        u_int32_t hid;
        int error;
 
+       KASSERT(krp != NULL);
+
        /* Sanity checks. */
-       if (krp == NULL)
-               return EINVAL;
        if (krp->krp_callback == NULL) {
                cv_destroy(&krp->krp_cv);
                pool_put(&cryptkop_pool, krp);
@@ -947,13 +953,13 @@
 {
        u_int32_t hid;
 
+       KASSERT(crp != NULL);
+
 #ifdef CRYPTO_TIMING
        if (crypto_timing)
                crypto_tstat(&cryptostats.cs_invoke, &crp->crp_tstamp);
 #endif
        /* Sanity checks. */
-       if (crp == NULL)
-               return EINVAL;
        if (crp->crp_callback == NULL) {
                return EINVAL;
        }
@@ -1063,6 +1069,8 @@
 {
        int wasempty;
 
+       KASSERT(crp != NULL);
+
        if (crp->crp_etype != 0)
                cryptostats.cs_errs++;
 #ifdef CRYPTO_TIMING
@@ -1145,6 +1153,8 @@
 {
        int wasempty;
 
+       KASSERT(krp != NULL);
+
        if (krp->krp_status != 0)
                cryptostats.cs_kerrs++;
                



Home | Main Index | Thread Index | Old Index