Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/dev Convert malloc -> kmem.
details: https://anonhg.NetBSD.org/src-all/rev/06bad28c2ab2
branches: trunk
changeset: 934492:06bad28c2ab2
user: Taylor R Campbell <riastradh%NetBSD.org@localhost>
date: Fri May 29 20:09:08 2020 +0000
description:
Convert malloc -> kmem.
diffstat:
sys/dev/cgd_crypto.c | 26 ++++++++++----------------
1 files changed, 10 insertions(+), 16 deletions(-)
diffs (99 lines):
diff -r 33fad3ce755f -r 06bad28c2ab2 sys/dev/cgd_crypto.c
--- a/sys/dev/cgd_crypto.c Fri May 29 19:57:12 2020 +0000
+++ b/sys/dev/cgd_crypto.c Fri May 29 20:09:08 2020 +0000
@@ -40,7 +40,7 @@
__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.17 2019/12/14 16:58:38 riastradh Exp $");
#include <sys/param.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/systm.h>
#include <dev/cgd_crypto.h>
@@ -196,9 +196,7 @@
*blocksize = 128;
if (*blocksize != 128)
return NULL;
- ap = malloc(sizeof(*ap), M_DEVBUF, 0);
- if (!ap)
- return NULL;
+ ap = kmem_zalloc(sizeof(*ap), KM_SLEEP);
rijndael_makeKey(&ap->ap_enckey, DIR_ENCRYPT, keylen, key);
rijndael_makeKey(&ap->ap_deckey, DIR_DECRYPT, keylen, key);
return ap;
@@ -210,7 +208,7 @@
struct aes_privdata *apd = data;
explicit_memset(apd, 0, sizeof(*apd));
- free(apd, M_DEVBUF);
+ kmem_free(apd, sizeof(*apd));
}
static void
@@ -286,10 +284,8 @@
*blocksize = 128;
if (*blocksize != 128)
return NULL;
- ap = malloc(2 * sizeof(*ap), M_DEVBUF, 0);
- if (!ap)
- return NULL;
+ ap = kmem_zalloc(2 * sizeof(*ap), KM_SLEEP);
keylen /= 2;
key = xtskey;
key2 = key + keylen / CHAR_BIT;
@@ -307,7 +303,7 @@
struct aes_privdata *apd = data;
explicit_memset(apd, 0, 2 * sizeof(*apd));
- free(apd, M_DEVBUF);
+ kmem_free(apd, 2 * sizeof(*apd));
}
static void
@@ -396,16 +392,14 @@
*blocksize = 64;
if (keylen != (DES_KEY_SZ * 3 * 8) || *blocksize != 64)
return NULL;
- cp = malloc(sizeof(*cp), M_DEVBUF, 0);
- if (!cp)
- return NULL;
+ cp = kmem_zalloc(sizeof(*cp), KM_SLEEP);
block = __UNCONST(key);
error = des_key_sched(block, cp->cp_key1);
error |= des_key_sched(block + 1, cp->cp_key2);
error |= des_key_sched(block + 2, cp->cp_key3);
if (error) {
explicit_memset(cp, 0, sizeof(*cp));
- free(cp, M_DEVBUF);
+ kmem_free(cp, sizeof(*cp));
return NULL;
}
return cp;
@@ -417,7 +411,7 @@
struct c3des_privdata *cp = data;
explicit_memset(cp, 0, sizeof(*cp));
- free(cp, M_DEVBUF);
+ kmem_free(cp, sizeof(*cp));
}
static void
@@ -496,7 +490,7 @@
*blocksize = 64;
if (*blocksize != 64)
return NULL;
- bp = malloc(sizeof(*bp), M_DEVBUF, 0);
+ bp = kmem_zalloc(sizeof(*bp), KM_SLEEP);
if (!bp)
return NULL;
BF_set_key(&bp->bp_key, keylen / 8, key);
@@ -509,7 +503,7 @@
struct bf_privdata *bp = data;
explicit_memset(bp, 0, sizeof(*bp));
- free(bp, M_DEVBUF);
+ kmem_free(bp, sizeof(*bp));
}
static void
Home |
Main Index |
Thread Index |
Old Index