From: LABBE Corentin <clabbe.montjoie@gmail.com>
To: axboe@fb.com, clabbe.montjoie@gmail.com,
cristian.stoica@freescale.com, dan.j.williams@intel.com,
davem@davemloft.net, herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/7] crypto: qce: check return value of sg_nents_for_len
Date: Wed, 4 Nov 2015 21:13:36 +0100 [thread overview]
Message-ID: <1446668045-8620-4-git-send-email-clabbe.montjoie@gmail.com> (raw)
In-Reply-To: <1446668045-8620-1-git-send-email-clabbe.montjoie@gmail.com>
The sg_nents_for_len() function could fail, this patch add a check for
its return value.
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
drivers/crypto/qce/ablkcipher.c | 8 ++++++++
drivers/crypto/qce/sha.c | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/drivers/crypto/qce/ablkcipher.c b/drivers/crypto/qce/ablkcipher.c
index 2c0d63d..dbcbbe2 100644
--- a/drivers/crypto/qce/ablkcipher.c
+++ b/drivers/crypto/qce/ablkcipher.c
@@ -83,6 +83,14 @@ qce_ablkcipher_async_req_handle(struct crypto_async_request *async_req)
rctx->dst_nents = sg_nents_for_len(req->dst, req->nbytes);
else
rctx->dst_nents = rctx->src_nents;
+ if (rctx->src_nents < 0) {
+ dev_err(qce->dev, "Invalid numbers of src SG.\n");
+ return rctx->src_nents;
+ }
+ if (rctx->dst_nents < 0) {
+ dev_err(qce->dev, "Invalid numbers of dst SG.\n");
+ return -rctx->dst_nents;
+ }
rctx->dst_nents += 1;
diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
index 0c9973e..47e114a 100644
--- a/drivers/crypto/qce/sha.c
+++ b/drivers/crypto/qce/sha.c
@@ -92,6 +92,11 @@ static int qce_ahash_async_req_handle(struct crypto_async_request *async_req)
}
rctx->src_nents = sg_nents_for_len(req->src, req->nbytes);
+ if (rctx->src_nents < 0) {
+ dev_err(qce->dev, "Invalid numbers of src SG.\n");
+ return rctx->src_nents;
+ }
+
ret = dma_map_sg(qce->dev, req->src, rctx->src_nents, DMA_TO_DEVICE);
if (ret < 0)
return ret;
--
2.4.10
next prev parent reply other threads:[~2015-11-04 20:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 20:13 [PATCH 1/7] crypto: marvell: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 2/7] crypto: talitos: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 3/7] crypto: sahara: " LABBE Corentin
2015-11-04 20:13 ` LABBE Corentin [this message]
2015-11-04 20:13 ` [PATCH 5/7] crypto: picoxcell: " LABBE Corentin
2015-11-06 15:30 ` Jamie Iles
2015-11-04 20:13 ` [PATCH 6/7] crypto: caam: " LABBE Corentin
2015-11-04 20:13 ` [PATCH 7/7] crypto: amcc: " LABBE Corentin
2015-11-17 14:09 ` [PATCH 1/7] crypto: marvell: " Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446668045-8620-4-git-send-email-clabbe.montjoie@gmail.com \
--to=clabbe.montjoie@gmail.com \
--cc=axboe@fb.com \
--cc=cristian.stoica@freescale.com \
--cc=dan.j.williams@intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®