summaryrefslogtreecommitdiff
path: root/sys/dev/softraid_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/softraid_crypto.c')
-rw-r--r--sys/dev/softraid_crypto.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c
index 2dc4c6b2328..c419686997e 100644
--- a/sys/dev/softraid_crypto.c
+++ b/sys/dev/softraid_crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid_crypto.c,v 1.132 2017/02/07 15:10:48 bluhm Exp $ */
+/* $OpenBSD: softraid_crypto.c,v 1.133 2017/02/07 17:25:46 patrick Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Hans-Joerg Hoexer <hshoexer@openbsd.org>
@@ -64,7 +64,6 @@ struct sr_crypto_wu {
struct uio cr_uio;
struct iovec cr_iov;
struct cryptop *cr_crp;
- struct cryptodesc *cr_descs;
void *cr_dmabuf;
};
@@ -270,15 +269,11 @@ sr_crypto_prepare(struct sr_workunit *wu, int encrypt)
/*
* We preallocated enough crypto descs for up to MAXPHYS of I/O.
- * Since there may be less than that we need to tweak the linked list
+ * Since there may be less than that we need to tweak the amount
* of crypto desc structures to be just long enough for our needs.
*/
- crd = crwu->cr_descs;
- for (i = 0; i < ((MAXPHYS >> DEV_BSHIFT) - n); i++) {
- crd = crd->crd_next;
- KASSERT(crd);
- }
- crwu->cr_crp->crp_desc = crd;
+ KASSERT(crwu->cr_crp->crp_ndescalloc >= n);
+ crwu->cr_crp->crp_ndesc = n;
flags = (encrypt ? CRD_F_ENCRYPT : 0) |
CRD_F_IV_PRESENT | CRD_F_IV_EXPLICIT;
@@ -297,8 +292,8 @@ sr_crypto_prepare(struct sr_workunit *wu, int encrypt)
crwu->cr_crp->crp_alloctype = M_DEVBUF;
crwu->cr_crp->crp_flags = CRYPTO_F_IOV | CRYPTO_F_NOQUEUE;
crwu->cr_crp->crp_buf = &crwu->cr_uio;
- for (i = 0, crd = crwu->cr_crp->crp_desc; crd;
- i++, blkno++, crd = crd->crd_next) {
+ for (i = 0; i < crwu->cr_crp->crp_ndesc; i++, blkno++) {
+ crd = &crwu->cr_crp->crp_desc[i];
crd->crd_skip = i << DEV_BSHIFT;
crd->crd_len = DEV_BSIZE;
crd->crd_inject = 0;
@@ -946,7 +941,6 @@ sr_crypto_alloc_resources(struct sr_discipline *sd)
crwu->cr_crp = crypto_getreq(MAXPHYS >> DEV_BSHIFT);
if (crwu->cr_crp == NULL)
return (ENOMEM);
- crwu->cr_descs = crwu->cr_crp->crp_desc;
}
memset(&cri, 0, sizeof(cri));
@@ -1005,10 +999,8 @@ sr_crypto_free_resources(struct sr_discipline *sd)
crwu = (struct sr_crypto_wu *)wu;
if (crwu->cr_dmabuf)
dma_free(crwu->cr_dmabuf, MAXPHYS);
- if (crwu->cr_crp) {
- crwu->cr_crp->crp_desc = crwu->cr_descs;
+ if (crwu->cr_crp)
crypto_freereq(crwu->cr_crp);
- }
}
sr_wu_free(sd);