svn commit: r285247 - head/sys/opencrypto
John-Mark Gurney
jmg at FreeBSD.org
Tue Jul 7 18:45:35 UTC 2015
Author: jmg
Date: Tue Jul 7 18:45:32 2015
New Revision: 285247
URL: https://svnweb.freebsd.org/changeset/base/285247
Log:
we may get here w/ non-sleepable locks held, so switch to _NOWAIT when
doing this memory allocation...
Reviewed by: ae
Modified:
head/sys/opencrypto/criov.c
head/sys/opencrypto/cryptodev.h
head/sys/opencrypto/cryptosoft.c
Modified: head/sys/opencrypto/criov.c
==============================================================================
--- head/sys/opencrypto/criov.c Tue Jul 7 18:44:27 2015 (r285246)
+++ head/sys/opencrypto/criov.c Tue Jul 7 18:45:32 2015 (r285247)
@@ -193,7 +193,7 @@ crypto_apply(int flags, caddr_t buf, int
return (error);
}
-void
+int
crypto_mbuftoiov(struct mbuf *mbuf, struct iovec **iovptr, int *cnt,
int *allocated)
{
@@ -216,7 +216,9 @@ crypto_mbuftoiov(struct mbuf *mbuf, stru
while ((mtmp = mtmp->m_next) != NULL)
j++;
iov = malloc(sizeof *iov * (i + j), M_CRYPTO_DATA,
- M_WAITOK);
+ M_NOWAIT);
+ if (iov == NULL)
+ return ENOMEM;
*allocated = 1;
*cnt = i + j;
memcpy(iov, *iovptr, sizeof *iov * i);
@@ -235,4 +237,5 @@ crypto_mbuftoiov(struct mbuf *mbuf, stru
*iovptr = iov;
*cnt = i;
+ return 0;
}
Modified: head/sys/opencrypto/cryptodev.h
==============================================================================
--- head/sys/opencrypto/cryptodev.h Tue Jul 7 18:44:27 2015 (r285246)
+++ head/sys/opencrypto/cryptodev.h Tue Jul 7 18:45:32 2015 (r285247)
@@ -465,7 +465,7 @@ extern int cuio_apply(struct uio *uio, i
struct mbuf;
struct iovec;
-extern void crypto_mbuftoiov(struct mbuf *mbuf, struct iovec **iovptr,
+extern int crypto_mbuftoiov(struct mbuf *mbuf, struct iovec **iovptr,
int *cnt, int *allocated);
extern void crypto_copyback(int flags, caddr_t buf, int off, int size,
Modified: head/sys/opencrypto/cryptosoft.c
==============================================================================
--- head/sys/opencrypto/cryptosoft.c Tue Jul 7 18:44:27 2015 (r285246)
+++ head/sys/opencrypto/cryptosoft.c Tue Jul 7 18:45:32 2015 (r285247)
@@ -147,8 +147,10 @@ swcr_encdec(struct cryptodesc *crd, stru
iovalloc = 0;
uio = &uiolcl;
if ((flags & CRYPTO_F_IMBUF) != 0) {
- crypto_mbuftoiov((struct mbuf *)buf, &iov, &iovcnt,
+ error = crypto_mbuftoiov((struct mbuf *)buf, &iov, &iovcnt,
&iovalloc);
+ if (error)
+ return (error);
uio->uio_iov = iov;
uio->uio_iovcnt = iovcnt;
} else if ((flags & CRYPTO_F_IOV) != 0)
More information about the svn-src-head
mailing list