From f91ab858cf2bcadcc5978ec919a40681906c4f01 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 15 Apr 2020 21:05:38 +0000 Subject: [PATCH] Use crypto_contiguous_subsegment(). This driver used a home-rolled version that predated the function and didn't support mbufs. --- sys/crypto/via/padlock_cipher.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/sys/crypto/via/padlock_cipher.c b/sys/crypto/via/padlock_cipher.c index 04cd0fbb575e..da5463c905d3 100644 --- a/sys/crypto/via/padlock_cipher.c +++ b/sys/crypto/via/padlock_cipher.c @@ -169,27 +169,9 @@ padlock_cipher_alloc(struct cryptop *crp, int *allocated) { u_char *addr; - switch (crp->crp_buf_type) { - case CRYPTO_BUF_MBUF: - break; - case CRYPTO_BUF_UIO: { - struct uio *uio; - struct iovec *iov; - - uio = crp->crp_uio; - if (uio->uio_iovcnt != 1) - break; - iov = uio->uio_iov; - addr = (u_char *)iov->iov_base + crp->crp_payload_start; - if (((uintptr_t)addr & 0xf) != 0) /* 16 bytes aligned? */ - break; - *allocated = 0; - return (addr); - } - case CRYPTO_BUF_CONTIG: - addr = (u_char *)crp->crp_buf + crp->crp_payload_start; - if (((uintptr_t)addr & 0xf) != 0) /* 16 bytes aligned? */ - break; + addr = crypto_contiguous_subsegment(crp, crp->crp_payload_start, + crp->crp_payload_length); + if (((uintptr_t)addr & 0xf) == 0) { /* 16 bytes aligned? */ *allocated = 0; return (addr); }