There's a rather futile check for wrap around in crypto.c. The problem
is, if the number of crypto devs is anywhere near wrapping, the
malloc call a few lines below has long since exploded.
Just define a static max count and don't go over it.
Index: crypto.c
===================================================================
RCS file: /cvs/src/sys/crypto/crypto.c,v
retrieving revision 1.59
diff -u -p -r1.59 crypto.c
--- crypto.c 11 Jan 2011 15:42:05 -0000 1.59
+++ crypto.c 26 Mar 2013 07:35:33 -0000
@@ -245,8 +245,7 @@ crypto_get_driverid(u_int8_t flags)
/* Out of entries, allocate some more. */
if (i == crypto_drivers_num) {
- /* Be careful about wrap-around. */
- if (2 * crypto_drivers_num <= crypto_drivers_num) {
+ if (crypto_drivers_num >= CRYPTO_DRIVERS_MAX) {
splx(s);
return -1;
}
Index: cryptodev.h
===================================================================
RCS file: /cvs/src/sys/crypto/cryptodev.h,v
retrieving revision 1.56
diff -u -p -r1.56 cryptodev.h
--- cryptodev.h 29 Jun 2012 14:48:04 -0000 1.56
+++ cryptodev.h 26 Mar 2013 07:35:54 -0000
@@ -57,6 +57,7 @@
/* Some initial values */
#define CRYPTO_DRIVERS_INITIAL 4
+#define CRYPTO_DRIVERS_MAX 128
#define CRYPTO_SW_SESSIONS 32
/* HMAC values */