Source-Changes-HG archive

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

[src/trunk]: src/sys/opencrypto fix missing mutex_exit() in crypto_destroy().



details:   https://anonhg.NetBSD.org/src/rev/a15d05fbcc03
branches:  trunk
changeset: 352385:a15d05fbcc03
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Wed Mar 29 23:02:43 2017 +0000

description:
fix missing mutex_exit() in crypto_destroy().

crypto_destroy() is called only in error case or unloading module.

diffstat:

 sys/opencrypto/crypto.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 6ffc8ae2e332 -r a15d05fbcc03 sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Wed Mar 29 22:48:03 2017 +0000
+++ b/sys/opencrypto/crypto.c   Wed Mar 29 23:02:43 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.50 2017/03/16 05:23:56 knakahara Exp $ */
+/*     $NetBSD: crypto.c,v 1.51 2017/03/29 23:02: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.50 2017/03/16 05:23:56 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.51 2017/03/29 23:02:43 knakahara Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -306,14 +306,18 @@
                mutex_spin_enter(&crypto_ret_q_mtx);
 
                /* if we have any in-progress requests, don't unload */
-               if (!TAILQ_EMPTY(&crp_q) || !TAILQ_EMPTY(&crp_kq))
+               if (!TAILQ_EMPTY(&crp_q) || !TAILQ_EMPTY(&crp_kq)) {
+                       mutex_spin_exit(&crypto_ret_q_mtx);
                        return EBUSY;
+               }
 
                for (i = 0; i < crypto_drivers_num; i++)
                        if (crypto_drivers[i].cc_sessions != 0)
                                break;
-               if (i < crypto_drivers_num)
+               if (i < crypto_drivers_num) {
+                       mutex_spin_exit(&crypto_ret_q_mtx);
                        return EBUSY;
+               }
 
                /* kick the cryptoret thread and wait for it to exit */
                crypto_exit_flag = 1;



Home | Main Index | Thread Index | Old Index