Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/opencrypto opencrypto: Assert nonnull callback up front ...
details: https://anonhg.NetBSD.org/src/rev/fc17cfef40a9
branches: trunk
changeset: 366338:fc17cfef40a9
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun May 22 11:39:54 2022 +0000
description:
opencrypto: Assert nonnull callback up front in crypto_dispatch.
Same with crypto_kdispatch.
Convert some dead branches downstream to assertions too.
diffstat:
sys/opencrypto/crypto.c | 25 +++++++------------------
1 files changed, 7 insertions(+), 18 deletions(-)
diffs (75 lines):
diff -r b7ba8ba0269e -r fc17cfef40a9 sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c Sun May 22 11:39:45 2022 +0000
+++ b/sys/opencrypto/crypto.c Sun May 22 11:39:54 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crypto.c,v 1.125 2022/05/22 11:39:37 riastradh Exp $ */
+/* $NetBSD: crypto.c,v 1.126 2022/05/22 11:39:54 riastradh 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.125 2022/05/22 11:39:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.126 2022/05/22 11:39:54 riastradh Exp $");
#include <sys/param.h>
#include <sys/reboot.h>
@@ -1283,6 +1283,7 @@
struct crypto_crp_q *crp_q;
KASSERT(crp != NULL);
+ KASSERT(crp->crp_callback != NULL);
KASSERT(crp->crp_desc != NULL);
KASSERT(crp->crp_buf != NULL);
KASSERT(!cpu_intr_p());
@@ -1395,6 +1396,7 @@
struct crypto_crp_kq *crp_kq;
KASSERT(krp != NULL);
+ KASSERT(krp->krp_callback != NULL);
KASSERT(!cpu_intr_p());
cryptostats.cs_kops++;
@@ -1462,15 +1464,9 @@
int error;
KASSERT(krp != NULL);
+ KASSERT(krp->krp_callback != NULL);
KASSERT(!cpu_intr_p());
- /* Sanity checks. */
- if (krp->krp_callback == NULL) {
- cv_destroy(&krp->krp_cv);
- crypto_kfreereq(krp);
- return EINVAL;
- }
-
mutex_enter(&crypto_drv_mtx);
for (hid = 0; hid < crypto_drivers_num; hid++) {
cap = crypto_checkdriver(hid);
@@ -1548,21 +1544,14 @@
struct cryptocap *cap;
KASSERT(crp != NULL);
+ KASSERT(crp->crp_callback != NULL);
+ KASSERT(crp->crp_desc != NULL);
KASSERT(!cpu_intr_p());
#ifdef CRYPTO_TIMING
if (crypto_timing)
crypto_tstat(&cryptostats.cs_invoke, &crp->crp_tstamp);
#endif
- /* Sanity checks. */
- if (crp->crp_callback == NULL) {
- return EINVAL;
- }
- if (crp->crp_desc == NULL) {
- crp->crp_etype = EINVAL;
- crypto_done(crp);
- return 0;
- }
cap = crypto_checkdriver_lock(CRYPTO_SESID2HID(crp->crp_sid));
if (cap != NULL && (cap->cc_flags & CRYPTOCAP_F_CLEANUP) == 0) {
Home |
Main Index |
Thread Index |
Old Index