summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2015-07-07 18:45:32 +0000
committerjmg <jmg@FreeBSD.org>2015-07-07 18:45:32 +0000
commit2679883c77799da43455e227a68be0d0f8e6356e (patch)
treee1043364630d52d1c41fa6e6a512fd955a14db9a
parent6ee39a4cd824e81d9be1c1f59cff7ae0aaf45c25 (diff)
downloadFreeBSD-src-2679883c77799da43455e227a68be0d0f8e6356e.zip
FreeBSD-src-2679883c77799da43455e227a68be0d0f8e6356e.tar.gz
we may get here w/ non-sleepable locks held, so switch to _NOWAIT when
doing this memory allocation... Reviewed by: ae
-rw-r--r--sys/opencrypto/criov.c7
-rw-r--r--sys/opencrypto/cryptodev.h2
-rw-r--r--sys/opencrypto/cryptosoft.c4
3 files changed, 9 insertions, 4 deletions
diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c
index f94631e..499bfe3 100644
--- a/sys/opencrypto/criov.c
+++ b/sys/opencrypto/criov.c
@@ -193,7 +193,7 @@ crypto_apply(int flags, caddr_t buf, int off, int len,
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, struct iovec **iovptr, int *cnt,
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, struct iovec **iovptr, int *cnt,
*iovptr = iov;
*cnt = i;
+ return 0;
}
diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h
index f434843..ab34b9e 100644
--- a/sys/opencrypto/cryptodev.h
+++ b/sys/opencrypto/cryptodev.h
@@ -465,7 +465,7 @@ extern int cuio_apply(struct uio *uio, int off, int len,
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,
diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c
index d769eea..77ab507 100644
--- a/sys/opencrypto/cryptosoft.c
+++ b/sys/opencrypto/cryptosoft.c
@@ -147,8 +147,10 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
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)
OpenPOWER on IntegriCloud