Module Name:    src
Committed By:   riastradh
Date:           Wed May 18 20:03:45 UTC 2022

Modified Files:
        src/sys/opencrypto: cryptodev.c

Log Message:
crypto(4): Narrow scope of cryptodev_mtx to cover wait.

No functional change intended -- this only removes an unnecessary
lock/unlock cycle in the error case.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/opencrypto/cryptodev.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/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.110 src/sys/opencrypto/cryptodev.c:1.111
--- src/sys/opencrypto/cryptodev.c:1.110	Wed May 18 20:03:32 2022
+++ src/sys/opencrypto/cryptodev.c	Wed May 18 20:03:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cryptodev.c,v 1.110 2022/05/18 20:03:32 riastradh Exp $ */
+/*	$NetBSD: cryptodev.c,v 1.111 2022/05/18 20:03:45 riastradh Exp $ */
 /*	$FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $	*/
 /*	$OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $	*/
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.110 2022/05/18 20:03:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.111 2022/05/18 20:03:45 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -653,7 +653,6 @@ cryptodev_op(struct csession *cse, struc
 	cv_init(&crp->crp_cv, "crydev");
 
 	error = crypto_dispatch(crp);
-	mutex_enter(&cryptodev_mtx);
 
 	/*
 	 * Don't touch crp before returned by any error or received
@@ -665,11 +664,11 @@ cryptodev_op(struct csession *cse, struc
 		break;
 	default:
 		DPRINTF("not waiting, error.\n");
-		mutex_exit(&cryptodev_mtx);
 		cv_destroy(&crp->crp_cv);
 		goto bail;
 	}
 
+	mutex_enter(&cryptodev_mtx);
 	while (!(crp->crp_devflags & CRYPTODEV_F_RET)) {
 		DPRINTF("cse->sid[%d]: sleeping on cv %p for crp %p\n",
 			(uint32_t)cse->sid, &crp->crp_cv, crp);

Reply via email to